polars.LazyFrame.groupby_rolling#
- LazyFrame.groupby_rolling(
- index_column: IntoExpr,
- *,
- period: str | timedelta,
- offset: str | timedelta | None = None,
- closed: ClosedInterval = 'right',
- by: IntoExpr | Iterable[IntoExpr] | None = None,
- check_sorted: bool | None = None,
Create rolling groups based on a time, Int32, or Int64 column.
Deprecated since version 0.19.0: This method has been renamed to
LazyFrame.rolling()
.- Parameters:
- index_column
Column used to group based on the time window. Often of type Date/Datetime. This column must be sorted in ascending order (or, if
by
is specified, then it must be sorted in ascending order within each group).In case of a rolling group by on indices, dtype needs to be one of {Int32, Int64}. Note that Int32 gets temporarily cast to Int64, so if performance matters use an Int64 column.
- period
length of the window - must be non-negative
- offset
offset of the window. Default is -period
- closed{‘right’, ‘left’, ‘both’, ‘none’}
Define which sides of the temporal interval are closed (inclusive).
- by
Also group by this column/these columns
- check_sorted
Check whether
index_column
is sorted (or, ifby
is given, check whether it’s sorted within each group). When theby
argument is given, polars can not check sortedness by the metadata and has to do a full scan on the index column to verify data is sorted. This is expensive. If you are sure the data within the groups is sorted, you can set this toFalse
. Doing so incorrectly will lead to incorrect output
- Returns:
- LazyGroupBy
Object you can call
.agg
on to aggregate by groups, the result of which will be sorted byindex_column
(but note that ifby
columns are passed, it will only be sorted within eachby
group).