polars.Series.cumulative_eval
-
Run an expression over a sliding window that increases
1slot every iteration.Warning
This functionality is considered unstable. It may be changed at any point without it being considered a breaking change.
Changed in version 1.21.0: The
min_periodsparameter was renamedmin_samples.- Parameters:
-
- expr
-
Expression to evaluate
- min_samples
-
Number of valid values there should be in the window before the expression is evaluated. valid values =
length - null_count - parallel
-
Run in parallel. Don’t do this in a group by or another operation that already has much parallelization.
Warning
This can be really slow as it can have
O(n^2)complexity. Don’t use this for operations that visit all elements.Examples
>>> s = pl.Series("values", [1, 2, 3, 4, 5]) >>> s.cumulative_eval(pl.element().first() - pl.element().last() ** 2) shape: (5,) Series: 'values' [i64] [ 0 -3 -8 -15 -24 ]
Series.cumulative_eval(
expr: Expr,
*,
min_samples: int = 1,
parallel: bool = False,
) → Series
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/series/api/polars.Series.cumulative_eval.html