Sha256: 309217acaad297595d652ba4be4fa256ce06d31919102877d8376c5a0400a85c

Contents?: true

Size: 1.94 KB

Versions: 15

Compression:

Stored size: 1.94 KB

Contents

module Polars
  # Namespace for array related expressions.
  class ArrayExpr
    # @private
    attr_accessor :_rbexpr

    # @private
    def initialize(expr)
      self._rbexpr = expr._rbexpr
    end

    # Compute the min values of the sub-arrays.
    #
    # @return [Expr]
    #
    # @example
    #   df = Polars::DataFrame.new(
    #     {"a" => [[1, 2], [4, 3]]},
    #     schema: {"a" => Polars::Array.new(2, Polars::Int64)}
    #   )
    #   df.select(Polars.col("a").arr.min)
    #   # =>
    #   # shape: (2, 1)
    #   # ┌─────┐
    #   # │ a   │
    #   # │ --- │
    #   # │ i64 │
    #   # ╞═════╡
    #   # │ 1   │
    #   # │ 3   │
    #   # └─────┘
    def min
      Utils.wrap_expr(_rbexpr.array_min)
    end

    # Compute the max values of the sub-arrays.
    #
    # @return [Expr]
    #
    # @example
    #   df = Polars::DataFrame.new(
    #     {"a" => [[1, 2], [4, 3]]},
    #     schema: {"a" => Polars::Array.new(2, Polars::Int64)}
    #   )
    #   df.select(Polars.col("a").arr.max)
    #   # =>
    #   # shape: (2, 1)
    #   # ┌─────┐
    #   # │ a   │
    #   # │ --- │
    #   # │ i64 │
    #   # ╞═════╡
    #   # │ 2   │
    #   # │ 4   │
    #   # └─────┘
    def max
      Utils.wrap_expr(_rbexpr.array_max)
    end

    # Compute the sum values of the sub-arrays.
    #
    # @return [Expr]
    #
    # @example
    #   df = Polars::DataFrame.new(
    #     {"a" => [[1, 2], [4, 3]]},
    #     schema: {"a" => Polars::Array.new(2, Polars::Int64)}
    #   )
    #   df.select(Polars.col("a").arr.sum)
    #   # =>
    #   # shape: (2, 1)
    #   # ┌─────┐
    #   # │ a   │
    #   # │ --- │
    #   # │ i64 │
    #   # ╞═════╡
    #   # │ 3   │
    #   # │ 7   │
    #   # └─────┘
    def sum
      Utils.wrap_expr(_rbexpr.array_sum)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
polars-df-0.8.0-x86_64-linux lib/polars/array_expr.rb
polars-df-0.8.0-x86_64-darwin lib/polars/array_expr.rb
polars-df-0.8.0-arm64-darwin lib/polars/array_expr.rb
polars-df-0.8.0-aarch64-linux lib/polars/array_expr.rb
polars-df-0.8.0 lib/polars/array_expr.rb
polars-df-0.7.0-x86_64-linux lib/polars/array_expr.rb
polars-df-0.7.0-x86_64-darwin lib/polars/array_expr.rb
polars-df-0.7.0-arm64-darwin lib/polars/array_expr.rb
polars-df-0.7.0-aarch64-linux lib/polars/array_expr.rb
polars-df-0.7.0 lib/polars/array_expr.rb
polars-df-0.6.0-x86_64-linux lib/polars/array_expr.rb
polars-df-0.6.0-x86_64-darwin lib/polars/array_expr.rb
polars-df-0.6.0-arm64-darwin lib/polars/array_expr.rb
polars-df-0.6.0-aarch64-linux lib/polars/array_expr.rb
polars-df-0.6.0 lib/polars/array_expr.rb