Class: Polars::ArrayExpr

Inherits:
Object
  • Object
show all
Defined in:
lib/polars/array_expr.rb

Overview

Namespace for array related expressions.

Instance Method Summary collapse

Instance Method Details

#maxExpr

Compute the max values of the sub-arrays.

Examples:

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   │
# └─────┘


56
57
58
# File 'lib/polars/array_expr.rb', line 56

def max
  Utils.wrap_expr(_rbexpr.array_max)
end

#minExpr

Compute the min values of the sub-arrays.

Examples:

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   │
# └─────┘


32
33
34
# File 'lib/polars/array_expr.rb', line 32

def min
  Utils.wrap_expr(_rbexpr.array_min)
end

#sumExpr

Compute the sum values of the sub-arrays.

Examples:

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   │
# └─────┘


80
81
82
# File 'lib/polars/array_expr.rb', line 80

def sum
  Utils.wrap_expr(_rbexpr.array_sum)
end