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

Version Path
polars-df-0.15.0-x86_64-linux lib/polars/rolling_group_by.rb
polars-df-0.15.0-x86_64-linux-musl lib/polars/rolling_group_by.rb
polars-df-0.15.0-x86_64-darwin lib/polars/rolling_group_by.rb
polars-df-0.15.0-x64-mingw-ucrt lib/polars/rolling_group_by.rb
polars-df-0.15.0-arm64-darwin lib/polars/rolling_group_by.rb
polars-df-0.15.0-aarch64-linux lib/polars/rolling_group_by.rb
polars-df-0.15.0-aarch64-linux-musl lib/polars/rolling_group_by.rb
polars-df-0.15.0 lib/polars/rolling_group_by.rb
polars-df-0.14.0-x86_64-linux lib/polars/rolling_group_by.rb
polars-df-0.14.0-x86_64-linux-musl lib/polars/rolling_group_by.rb
polars-df-0.14.0-x86_64-darwin lib/polars/rolling_group_by.rb
polars-df-0.14.0-x64-mingw-ucrt lib/polars/rolling_group_by.rb
polars-df-0.14.0-arm64-darwin lib/polars/rolling_group_by.rb
polars-df-0.14.0-aarch64-linux lib/polars/rolling_group_by.rb
polars-df-0.14.0-aarch64-linux-musl lib/polars/rolling_group_by.rb
polars-df-0.14.0 lib/polars/rolling_group_by.rb
polars-df-0.13.0-x86_64-linux lib/polars/rolling_group_by.rb
polars-df-0.13.0-x86_64-linux-musl lib/polars/rolling_group_by.rb
polars-df-0.13.0-x86_64-darwin lib/polars/rolling_group_by.rb
polars-df-0.13.0-x64-mingw-ucrt lib/polars/rolling_group_by.rb