Class: Polars::RollingGroupBy
- Inherits:
-
Object
- Object
- Polars::RollingGroupBy
- Defined in:
- lib/polars/rolling_group_by.rb
Overview
A rolling grouper.
This has an .agg
method which will allow you to run all polars expressions in a
groupby context.
Instance Method Summary collapse
- #agg(aggs) ⇒ Object
-
#initialize(df, index_column, period, offset, closed, by) ⇒ RollingGroupBy
constructor
A new instance of RollingGroupBy.
Constructor Details
#initialize(df, index_column, period, offset, closed, by) ⇒ RollingGroupBy
Returns a new instance of RollingGroupBy.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/polars/rolling_group_by.rb', line 7 def initialize( df, index_column, period, offset, closed, by ) period = Utils._timedelta_to_pl_duration(period) offset = Utils._timedelta_to_pl_duration(offset) @df = df @time_column = index_column @period = period @offset = offset @closed = closed @by = by end |
Instance Method Details
#agg(aggs) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/polars/rolling_group_by.rb', line 26 def agg(aggs) @df.lazy .groupby_rolling( index_column: @time_column, period: @period, offset: @offset, closed: @closed, by: @by ) .agg(aggs) .collect(no_optimization: true, string_cache: false) end |