Class: Polars::DynamicGroupBy
- Inherits:
-
Object
- Object
- Polars::DynamicGroupBy
- Defined in:
- lib/polars/dynamic_group_by.rb
Overview
A dynamic grouper.
This has an .agg
method which allows you to run all polars expressions in a
group by context.
Instance Method Summary collapse
- #agg(*aggs, **named_aggs) ⇒ Object
-
#initialize(df, index_column, every, period, offset, truncate, include_boundaries, closed, by, start_by) ⇒ DynamicGroupBy
constructor
A new instance of DynamicGroupBy.
Constructor Details
#initialize(df, index_column, every, period, offset, truncate, include_boundaries, closed, by, start_by) ⇒ DynamicGroupBy
Returns a new instance of DynamicGroupBy.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/polars/dynamic_group_by.rb', line 7 def initialize( df, index_column, every, period, offset, truncate, include_boundaries, closed, by, start_by ) period = Utils.parse_as_duration_string(period) offset = Utils.parse_as_duration_string(offset) every = Utils.parse_as_duration_string(every) @df = df @time_column = index_column @every = every @period = period @offset = offset @truncate = truncate @include_boundaries = include_boundaries @closed = closed @by = by @start_by = start_by end |
Instance Method Details
#agg(*aggs, **named_aggs) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/polars/dynamic_group_by.rb', line 35 def agg(*aggs, **named_aggs) @df.lazy .group_by_dynamic( @time_column, every: @every, period: @period, offset: @offset, truncate: @truncate, include_boundaries: @include_boundaries, closed: @closed, by: @by, start_by: @start_by ) .agg(*aggs, **named_aggs) .collect(no_optimization: true, string_cache: false) end |