polars.Series.rolling_mean
-
Apply a rolling mean (moving mean) over the values in this array.
A window of length
window_sizewill traverse the array. The values that fill this window will (optionally) be multiplied with the weights given by theweightvector. The resulting values will be aggregated to their mean.The window at a given row will include the row itself and the
window_size - 1elements before it.Changed in version 1.21.0: The
min_periodsparameter was renamedmin_samples.- Parameters:
-
- window_size
-
The length of the window in number of elements.
- weights
-
An optional slice with the same length as the window that will be multiplied elementwise with the values in the window.
- min_samples
-
The number of values in the window that should be non-null before computing a result. If set to
None(default), it will be set equal towindow_size. - center
-
Set the labels at the center of the window.
Examples
>>> s = pl.Series("a", [100, 200, 300, 400, 500]) >>> s.rolling_mean(window_size=2) shape: (5,) Series: 'a' [f64] [ null 150.0 250.0 350.0 450.0 ]
Series.rolling_mean(
window_size: int,
weights: list_[float] | None = None,
*,
min_samples: int | None = None,
center: 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.rolling_mean.html