Sha256: 349c0561c885d2272b726cadd6b1bb3211724308983749bb23030e62970f4b0e

Contents?: true

Size: 881 Bytes

Versions: 21

Compression:

Stored size: 881 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,
      by,
      check_sorted
    )
      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
      @check_sorted = check_sorted
    end

    def agg(aggs)
      @df.lazy
        .group_by_rolling(
          index_column: @time_column, period: @period, offset: @offset, closed: @closed, by: @by, check_sorted: @check_sorted
        )
        .agg(aggs)
        .collect(no_optimization: true, string_cache: false)
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
polars-df-0.10.0-x86_64-linux lib/polars/rolling_group_by.rb
polars-df-0.10.0-x86_64-linux-musl lib/polars/rolling_group_by.rb
polars-df-0.10.0-x86_64-darwin lib/polars/rolling_group_by.rb
polars-df-0.10.0-arm64-darwin lib/polars/rolling_group_by.rb
polars-df-0.10.0-aarch64-linux lib/polars/rolling_group_by.rb
polars-df-0.10.0 lib/polars/rolling_group_by.rb
polars-df-0.9.0-x86_64-linux lib/polars/rolling_group_by.rb
polars-df-0.9.0-x86_64-darwin lib/polars/rolling_group_by.rb
polars-df-0.9.0-arm64-darwin lib/polars/rolling_group_by.rb
polars-df-0.9.0-aarch64-linux lib/polars/rolling_group_by.rb
polars-df-0.9.0 lib/polars/rolling_group_by.rb
polars-df-0.8.0-x86_64-linux lib/polars/rolling_group_by.rb
polars-df-0.8.0-x86_64-darwin lib/polars/rolling_group_by.rb
polars-df-0.8.0-arm64-darwin lib/polars/rolling_group_by.rb
polars-df-0.8.0-aarch64-linux lib/polars/rolling_group_by.rb
polars-df-0.8.0 lib/polars/rolling_group_by.rb
polars-df-0.7.0-x86_64-linux lib/polars/rolling_group_by.rb
polars-df-0.7.0-x86_64-darwin lib/polars/rolling_group_by.rb
polars-df-0.7.0-arm64-darwin lib/polars/rolling_group_by.rb
polars-df-0.7.0-aarch64-linux lib/polars/rolling_group_by.rb