Skip to content

innovate.rolling_average

All current Python definitions

View source · Source file SHA-256: 522871fe0b61b840b5f85b8f278beb2b79c7afd68645265ae3a68983d56d74e4

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.

  • data: Numeric Polars Series in the desired sample order; no sorting occurs.
  • window: Positive number of consecutive samples in each trailing window.

Series of trailing means, with leading nulls until a full window exists. Windows lacking enough non-null observations also follow Polars semantics.

  • ValueError: If window is 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.