Method: Polars::ArrayNameSpace#get

Defined in:
lib/polars/array_name_space.rb

#get(index, null_on_oob: false) ⇒ Series

Get the value by index in the sub-arrays.

So index 0 would return the first item of every sublist and index -1 would return the last item of every sublist if an index is out of bounds, it will return a nil.

Examples:

s = Polars::Series.new(
  "a", [[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype: Polars::Array.new(Polars::Int32, 3)
)
s.arr.get(Polars::Series.new([1, -2, 4]), null_on_oob: true)
# =>
# shape: (3,)
# Series: 'a' [i32]
# [
#         2
#         5
#         null
# ]

Parameters:

  • index (Integer)

    Index to return per sublist

  • null_on_oob (Boolean) (defaults to: false)

    Behavior if an index is out of bounds: true -> set as null false -> raise an error

Returns:



518
519
520
# File 'lib/polars/array_name_space.rb', line 518

def get(index, null_on_oob: false)
  super
end