polars.Expr.rolling_apply#

Expr.rolling_apply(
function: Callable[[Series], Any],
window_size: int,
weights: list[float] | None = None,
min_periods: int | None = None,
*,
center: bool = False,
) Self[source]#

Apply a custom rolling window function.

Deprecated since version 0.19.0: This method has been renamed to Expr.rolling_map().

Parameters:
function

Aggregation function

window_size

The length of the window.

weights

An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.

min_periods

The number of values in the window that should be non-null before computing a result. If None, it will be set equal to:

  • the window size, if window_size is a fixed integer

  • 1, if window_size is a dynamic temporal size

center

Set the labels at the center of the window