Class: Polars::ArrayNameSpace
- Inherits:
-
Object
- Object
- Polars::ArrayNameSpace
- Defined in:
- lib/polars/array_name_space.rb
Overview
Series.arr namespace.
Instance Method Summary collapse
-
#all ⇒ Series
Evaluate whether all boolean values are true for every subarray.
-
#any ⇒ Series
Evaluate whether any boolean value is true for every subarray.
-
#arg_max ⇒ Series
Retrieve the index of the maximum value in every sub-array.
-
#arg_min ⇒ Series
Retrieve the index of the minimal value in every sub-array.
-
#contains(item) ⇒ Series
Check if sub-arrays contain the given item.
-
#count_matches(element) ⇒ Series
Count how often the value produced by
element
occurs. -
#explode ⇒ Series
Returns a column with a separate row for every array element.
-
#first ⇒ Series
Get the first value of the sub-arrays.
-
#get(index) ⇒ Series
Get the value by index in the sub-arrays.
-
#head(n = 5, as_array: false) ⇒ Series
Get the first
n
elements of the sub-arrays. -
#join(separator, ignore_nulls: true) ⇒ Series
Join all string items in a sub-array and place a separator between them.
-
#last ⇒ Series
Get the last value of the sub-arrays.
-
#len ⇒ Series
Return the number of elements in each array.
-
#max ⇒ Series
Compute the max values of the sub-arrays.
-
#median ⇒ Series
Compute the median of the values of the sub-arrays.
-
#min ⇒ Series
Compute the min values of the sub-arrays.
-
#n_unique ⇒ Series
Count the number of unique values in every sub-arrays.
-
#reverse ⇒ Series
Reverse the arrays in this column.
-
#shift(n = 1) ⇒ Series
Shift array values by the given number of indices.
-
#slice(offset, length = nil, as_array: false) ⇒ Series
Slice the sub-arrays.
-
#sort(descending: false, nulls_last: false) ⇒ Series
Sort the arrays in this column.
-
#std(ddof: 1) ⇒ Series
Compute the std of the values of the sub-arrays.
-
#sum ⇒ Series
Compute the sum values of the sub-arrays.
-
#tail(n = 5, as_array: false) ⇒ Series
Slice the last
n
values of every sublist. -
#to_list ⇒ Series
Convert an Array column into a List column with the same inner data type.
-
#to_struct(fields: nil) ⇒ Series
Convert the series of type
Array
to a series of typeStruct
. -
#unique(maintain_order: false) ⇒ Series
Get the unique/distinct values in the array.
-
#var(ddof: 1) ⇒ Series
Compute the var of the values of the sub-arrays.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Polars::ExprDispatch
Instance Method Details
#all ⇒ Series
Evaluate whether all boolean values are true for every subarray.
381 382 383 |
# File 'lib/polars/array_name_space.rb', line 381 def all super end |
#any ⇒ Series
Evaluate whether any boolean value is true for every subarray.
215 216 217 |
# File 'lib/polars/array_name_space.rb', line 215 def any super end |
#arg_max ⇒ Series
Retrieve the index of the maximum value in every sub-array.
468 469 470 |
# File 'lib/polars/array_name_space.rb', line 468 def arg_max super end |
#arg_min ⇒ Series
Retrieve the index of the minimal value in every sub-array.
450 451 452 |
# File 'lib/polars/array_name_space.rb', line 450 def arg_min super end |
#contains(item) ⇒ Series
Check if sub-arrays contain the given item.
612 613 614 |
# File 'lib/polars/array_name_space.rb', line 612 def contains(item) super end |
#count_matches(element) ⇒ Series
Count how often the value produced by element
occurs.
633 634 635 |
# File 'lib/polars/array_name_space.rb', line 633 def count_matches(element) super end |
#explode ⇒ Series
Returns a column with a separate row for every array element.
588 589 590 |
# File 'lib/polars/array_name_space.rb', line 588 def explode super end |
#first ⇒ Series
Get the first value of the sub-arrays.
517 518 519 |
# File 'lib/polars/array_name_space.rb', line 517 def first super end |
#get(index) ⇒ 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
.
496 497 498 |
# File 'lib/polars/array_name_space.rb', line 496 def get(index) super end |
#head(n = 5, as_array: false) ⇒ Series
Get the first n
elements of the sub-arrays.
320 321 322 |
# File 'lib/polars/array_name_space.rb', line 320 def head(n = 5, as_array: false) super end |
#join(separator, ignore_nulls: true) ⇒ Series
Join all string items in a sub-array and place a separator between them.
This errors if inner type of array != String
.
566 567 568 |
# File 'lib/polars/array_name_space.rb', line 566 def join(separator, ignore_nulls: true) super end |
#last ⇒ Series
Get the last value of the sub-arrays.
538 539 540 |
# File 'lib/polars/array_name_space.rb', line 538 def last super end |
#len ⇒ Series
Return the number of elements in each array.
233 234 235 |
# File 'lib/polars/array_name_space.rb', line 233 def len super end |
#max ⇒ Series
Compute the max values of the sub-arrays.
49 50 51 |
# File 'lib/polars/array_name_space.rb', line 49 def max super end |
#median ⇒ Series
Compute the median of the values of the sub-arrays.
127 128 129 |
# File 'lib/polars/array_name_space.rb', line 127 def median super end |
#min ⇒ Series
Compute the min values of the sub-arrays.
29 30 31 |
# File 'lib/polars/array_name_space.rb', line 29 def min super end |
#n_unique ⇒ Series
Count the number of unique values in every sub-arrays.
173 174 175 |
# File 'lib/polars/array_name_space.rb', line 173 def n_unique super end |
#reverse ⇒ Series
Reverse the arrays in this column.
432 433 434 |
# File 'lib/polars/array_name_space.rb', line 432 def reverse super end |
#shift(n = 1) ⇒ Series
This method is similar to the LAG
operation in SQL when the value for n
is positive. With a negative value for n
, it is similar to LEAD
.
Shift array values by the given number of indices.
700 701 702 |
# File 'lib/polars/array_name_space.rb', line 700 def shift(n = 1) super end |
#slice(offset, length = nil, as_array: false) ⇒ Series
Slice the sub-arrays.
279 280 281 282 283 284 285 |
# File 'lib/polars/array_name_space.rb', line 279 def slice( offset, length = nil, as_array: false ) super end |
#sort(descending: false, nulls_last: false) ⇒ Series
Sort the arrays in this column.
414 415 416 |
# File 'lib/polars/array_name_space.rb', line 414 def sort(descending: false, nulls_last: false) super end |
#std(ddof: 1) ⇒ Series
Compute the std of the values of the sub-arrays.
91 92 93 |
# File 'lib/polars/array_name_space.rb', line 91 def std(ddof: 1) super end |
#sum ⇒ Series
Compute the sum values of the sub-arrays.
73 74 75 |
# File 'lib/polars/array_name_space.rb', line 73 def sum super end |
#tail(n = 5, as_array: false) ⇒ Series
Slice the last n
values of every sublist.
357 358 359 |
# File 'lib/polars/array_name_space.rb', line 357 def tail(n = 5, as_array: false) super end |
#to_list ⇒ Series
Convert an Array column into a List column with the same inner data type.
191 192 193 |
# File 'lib/polars/array_name_space.rb', line 191 def to_list super end |
#to_struct(fields: nil) ⇒ Series
Convert the series of type Array
to a series of type Struct
.
661 662 663 664 665 666 |
# File 'lib/polars/array_name_space.rb', line 661 def to_struct( fields: nil ) s = Utils.wrap_s(_s) s.to_frame.select(F.col(s.name).arr.to_struct(fields: fields)).to_series end |
#unique(maintain_order: false) ⇒ Series
Get the unique/distinct values in the array.
155 156 157 |
# File 'lib/polars/array_name_space.rb', line 155 def unique(maintain_order: false) super end |
#var(ddof: 1) ⇒ Series
Compute the var of the values of the sub-arrays.
109 110 111 |
# File 'lib/polars/array_name_space.rb', line 109 def var(ddof: 1) super end |