Sha256: 0fbe63d2fa9b2aa4d33b7e8b9fe37e45972e00e1965e1b2c601ecbc5827d3513

Contents?: true

Size: 1.52 KB

Versions: 15

Compression:

Stored size: 1.52 KB

Contents

module Polars
  # Series.arr namespace.
  class ArrayNameSpace
    include ExprDispatch

    self._accessor = "arr"

    # @private
    def initialize(series)
      self._s = series._s
    end

    # Compute the min values of the sub-arrays.
    #
    # @return [Series]
    #
    # @example
    #   s = Polars::Series.new(
    #     "a", [[1, 2], [4, 3]], dtype: Polars::Array.new(2, Polars::Int64)
    #   )
    #   s.arr.min
    #   # =>
    #   # shape: (2,)
    #   # Series: 'a' [i64]
    #   # [
    #   #         1
    #   #         3
    #   # ]
    def min
      super
    end

    # Compute the max values of the sub-arrays.
    #
    # @return [Series]
    #
    # @example
    #   s = Polars::Series.new(
    #     "a", [[1, 2], [4, 3]], dtype: Polars::Array.new(2, Polars::Int64)
    #   )
    #   s.arr.max
    #   # =>
    #   # shape: (2,)
    #   # Series: 'a' [i64]
    #   # [
    #   #         2
    #   #         4
    #   # ]
    def max
      super
    end

    # Compute the sum values of the sub-arrays.
    #
    # @return [Series]
    #
    # @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
      super
    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_name_space.rb
polars-df-0.8.0-x86_64-darwin lib/polars/array_name_space.rb
polars-df-0.8.0-arm64-darwin lib/polars/array_name_space.rb
polars-df-0.8.0-aarch64-linux lib/polars/array_name_space.rb
polars-df-0.8.0 lib/polars/array_name_space.rb
polars-df-0.7.0-x86_64-linux lib/polars/array_name_space.rb
polars-df-0.7.0-x86_64-darwin lib/polars/array_name_space.rb
polars-df-0.7.0-arm64-darwin lib/polars/array_name_space.rb
polars-df-0.7.0-aarch64-linux lib/polars/array_name_space.rb
polars-df-0.7.0 lib/polars/array_name_space.rb
polars-df-0.6.0-x86_64-linux lib/polars/array_name_space.rb
polars-df-0.6.0-x86_64-darwin lib/polars/array_name_space.rb
polars-df-0.6.0-arm64-darwin lib/polars/array_name_space.rb
polars-df-0.6.0-aarch64-linux lib/polars/array_name_space.rb
polars-df-0.6.0 lib/polars/array_name_space.rb