polars.Series.rolling_quantile
-
Compute a rolling quantile.
The window at a given row will include the row itself and the
window_size - 1elements before it.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:
-
- quantile
-
Quantile between 0.0 and 1.0.
-
interpolation{‘nearest’, ‘higher’, ‘lower’, ‘midpoint’, ‘linear’, ‘equiprobable’} -
Interpolation method.
- 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", [1.0, 2.0, 3.0, 4.0, 6.0, 8.0]) >>> s.rolling_quantile(quantile=0.33, window_size=3) shape: (6,) Series: 'a' [f64] [ null null 2.0 3.0 4.0 6.0 ] >>> s.rolling_quantile(quantile=0.33, interpolation="linear", window_size=3) shape: (6,) Series: 'a' [f64] [ null null 1.66 2.66 3.66 5.32 ]
Series.rolling_quantile(
quantile: float,
interpolation: QuantileMethod = 'nearest',
window_size: int = 2,
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_quantile.html