innovate.rolling_average
All current Python definitions
View source · Source file SHA-256: 522871fe0b61b840b5f85b8f278beb2b79c7afd68645265ae3a68983d56d74e4
Signature
Section titled “Signature”def rolling_average(data: pl.Series, window: int) -> pl.Series: ...Compute trailing means, requiring a complete observation window.
Polars computes the initial result. If a complete window of finite inputs produces a non-finite mean, a native numerically guarded calculation repairs that window. Null and non-finite input windows retain Polars’ behaviour.
Parameters
Section titled “Parameters”data: Numeric Polars Series in the desired sample order; no sorting occurs.window: Positive number of consecutive samples in each trailing window.
Returns
Section titled “Returns”Series of trailing means, with leading nulls until a full window exists. Windows lacking enough non-null observations also follow Polars semantics.
Raises
Section titled “Raises”ValueError: Ifwindowis less than one.NativeError: If a required native repair cannot be computed.TypeError: If the window or data cannot be processed with the supplied types.polars.exceptions.PolarsError: If the dtype does not support the operations.