Sha256: b4eaf093e6dc045aa44b36a76979512c1e20389df334d10cb46a91ca5c3bf30d
Contents?: true
Size: 849 Bytes
Versions: 30
Compression:
Stored size: 849 Bytes
Contents
module Polars # A rolling grouper. # # This has an `.agg` method which will allow you to run all polars expressions in a # group by context. class RollingGroupBy def initialize( df, index_column, period, offset, closed, group_by ) period = Utils.parse_as_duration_string(period) offset = Utils.parse_as_duration_string(offset) @df = df @time_column = index_column @period = period @offset = offset @closed = closed @group_by = group_by end def agg(*aggs, **named_aggs) @df.lazy .group_by_rolling( index_column: @time_column, period: @period, offset: @offset, closed: @closed, by: @group_by ) .agg(*aggs, **named_aggs) .collect(no_optimization: true, string_cache: false) end end end
Version data entries
30 entries across 30 versions & 1 rubygems