pandas.Series.cumsum

Return cumulative sum over a DataFrame or Series axis.

Returns a DataFrame or Series of the same size containing the cumulative sum.

param axis
{0 or ‘index’, 1 or ‘columns’}, default 0

The index or the name of the axis. 0 is equivalent to None or ‘index’.

param skipna
boolean, default True

Exclude NA/null values. If an entire row/column is NA, the result will be NA. *args, **kwargs : Additional keywords have no effect but might be accepted for compatibility with NumPy.

return

scalar or Series

Limitations

Parameter axis is supported only with default value None.

Examples

Returns cumulative sum over Series.
import pandas as pd
from numba import njit


@njit
def series_cumsum():
    s = pd.Series([1, 2, 3, 4])

    return s.cumsum()  # Expect series of 1, 3, 6, 10


print(series_cumsum())
$ python ./series/series_cumsum.py
0     1
1     3
2     6
3    10
dtype: int64

See also

Series.sum

Return the sum over Series.

Series.cummax

Return cumulative maximum over Series.

Series.cummin

Return cumulative minimum over Series.

Series.cumprod

Return cumulative product over Series.