polars.cumsum#

polars.cumsum(exprs: Series) Series[source]#
polars.cumsum(exprs: IntoExpr | Iterable[IntoExpr], *more_exprs: IntoExpr) Expr

Cumulatively sum all values.

If a single string is passed, this is an alias for pl.col(name).cumsum().

If a single Series is passed, this is an alias for Series.cumsum(). This functionality is deprecated.

Otherwise, this function computes the cumulative sum horizontally across multiple columns. This functionality is deprecated, use pl.cumsum_horizontal instead.

Parameters:
exprs

Column(s) to use in the aggregation. Accepts expression input. Strings are parsed as column names, other non-expression inputs are parsed as literals.

*more_exprs

Additional columns to use in the aggregation, specified as positional arguments.

Examples

>>> df = pl.DataFrame(
...     {
...         "a": [1, 2, 3],
...         "b": [4, 5, 6],
...     }
... )
>>> df.select(pl.cumsum("a"))
shape: (3, 1)
┌─────┐
│ a   │
│ --- │
│ i64 │
╞═════╡
│ 1   │
│ 3   │
│ 6   │
└─────┘