Class: Polars::ListNameSpace
- Inherits:
-
Object
- Object
- Polars::ListNameSpace
- Defined in:
- lib/polars/list_name_space.rb
Overview
Series.list namespace.
Instance Method Summary collapse
-
#[](item) ⇒ Series
Get the value by index in the sublists.
-
#agg(expr) ⇒ Series
Run any polars aggregation expression against the list' elements.
-
#all ⇒ Series
Evaluate whether all boolean values in a list are true.
-
#any ⇒ Series
Evaluate whether any boolean value in a list is true.
-
#arg_max ⇒ Series
Retrieve the index of the maximum value in every sublist.
-
#arg_min ⇒ Series
Retrieve the index of the minimal value in every sublist.
-
#concat(other) ⇒ Series
Concat the arrays in a Series dtype List in linear time.
-
#contains(item, nulls_equal: true) ⇒ Series
Check if sublists contain the given item.
-
#count_matches(element) ⇒ Series
Count how often the value produced by
elementoccurs. -
#diff(n: 1, null_behavior: "ignore") ⇒ Series
Calculate the n-th discrete difference of every sublist.
-
#drop_nulls ⇒ Series
Drop all null values in the list.
-
#eval(expr) ⇒ Series
Run any polars expression against the lists' elements.
-
#explode(empty_as_null: true, keep_nulls: true) ⇒ Series
Returns a column with a separate row for every list element.
-
#filter(predicate) ⇒ Series
Filter elements in each list by a boolean expression, returning a new Series of lists.
-
#first ⇒ Series
Get the first value of the sublists.
-
#gather(indices, null_on_oob: false) ⇒ Series
Take sublists by multiple indices.
-
#gather_every(n, offset = 0) ⇒ Series
Take every n-th value start from offset in sublists.
-
#get(index, null_on_oob: false) ⇒ Series
Get the value by index in the sublists.
-
#head(n = 5) ⇒ Series
Slice the first
nvalues of every sublist. -
#item ⇒ Series
Get the single value of the sublists.
-
#join(separator, ignore_nulls: true) ⇒ Series
Join all string items in a sublist and place a separator between them.
-
#last ⇒ Series
Get the last value of the sublists.
-
#len ⇒ Series
Get the length of the arrays as UInt32.
-
#max ⇒ Series
Compute the max value of the arrays in the list.
-
#mean ⇒ Series
Compute the mean value of the arrays in the list.
-
#median ⇒ Series
Compute the median value of the arrays in the list.
-
#min ⇒ Series
Compute the min value of the arrays in the list.
-
#n_unique ⇒ Series
Count the number of unique values in every sub-lists.
-
#reverse ⇒ Series
Reverse the arrays in the list.
-
#sample(n: nil, fraction: nil, with_replacement: false, shuffle: false, seed: nil) ⇒ Series
Sample from this list.
-
#set_difference(other) ⇒ Series
Compute the SET DIFFERENCE between the elements in this list and the elements of
other. -
#set_intersection(other) ⇒ Series
Compute the SET INTERSECTION between the elements in this list and the elements of
other. -
#set_symmetric_difference(other) ⇒ Series
Compute the SET SYMMETRIC DIFFERENCE between the elements in this list and the elements of
other. -
#set_union(other) ⇒ Series
Compute the SET UNION between the elements in this list and the elements of
other. -
#shift(n = 1) ⇒ Series
Shift values by the given period.
-
#slice(offset, length = nil) ⇒ Series
Slice every sublist.
-
#sort(descending: false, nulls_last: false) ⇒ Series
Sort the arrays in the list.
-
#std(ddof: 1) ⇒ Series
Compute the std value of the arrays in the list.
-
#sum ⇒ Series
Sum all the arrays in the list.
-
#tail(n = 5) ⇒ Series
Slice the last
nvalues of every sublist. -
#to_array(width) ⇒ Series
Convert a List column into an Array column with the same inner data type.
-
#to_struct(n_field_strategy: "first_non_null", fields: nil) ⇒ Series
Convert the series of type
Listto a series of typeStruct. -
#unique(maintain_order: false) ⇒ Series
Get the unique/distinct values in the list.
-
#var(ddof: 1) ⇒ Series
Compute the var value of the arrays in the list.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Polars::ExprDispatch
Instance Method Details
#[](item) ⇒ Series
Get the value by index in the sublists.
461 462 463 |
# File 'lib/polars/list_name_space.rb', line 461 def [](item) get(item) end |
#agg(expr) ⇒ Series
Run any polars aggregation expression against the list' elements.
895 896 897 |
# File 'lib/polars/list_name_space.rb', line 895 def agg(expr) super end |
#all ⇒ Series
Evaluate whether all boolean values in a list are true.
34 35 36 |
# File 'lib/polars/list_name_space.rb', line 34 def all super end |
#any ⇒ Series
Evaluate whether any boolean value in a list is true.
59 60 61 |
# File 'lib/polars/list_name_space.rb', line 59 def any super end |
#arg_max ⇒ Series
Retrieve the index of the maximum value in every sublist.
608 609 610 |
# File 'lib/polars/list_name_space.rb', line 608 def arg_max super end |
#arg_min ⇒ Series
Retrieve the index of the minimal value in every sublist.
590 591 592 |
# File 'lib/polars/list_name_space.rb', line 590 def arg_min super end |
#concat(other) ⇒ Series
Concat the arrays in a Series dtype List in linear time.
367 368 369 |
# File 'lib/polars/list_name_space.rb', line 367 def concat(other) super end |
#contains(item, nulls_equal: true) ⇒ Series
Check if sublists contain the given item.
572 573 574 |
# File 'lib/polars/list_name_space.rb', line 572 def contains(item, nulls_equal: true) super end |
#count_matches(element) ⇒ Series
Count how often the value produced by element occurs.
769 770 771 |
# File 'lib/polars/list_name_space.rb', line 769 def count_matches(element) super end |
#diff(n: 1, null_behavior: "ignore") ⇒ Series
Calculate the n-th discrete difference of every sublist.
631 632 633 |
# File 'lib/polars/list_name_space.rb', line 631 def diff(n: 1, null_behavior: "ignore") super end |
#drop_nulls ⇒ Series
Drop all null values in the list.
The original order of the remaining elements is preserved.
98 99 100 |
# File 'lib/polars/list_name_space.rb', line 98 def drop_nulls super end |
#eval(expr) ⇒ Series
Run any polars expression against the lists' elements.
861 862 863 864 |
# File 'lib/polars/list_name_space.rb', line 861 def eval(expr) s = Utils.wrap_s(_s) s.to_frame.select(F.col(s.name).list.eval(expr)).to_series end |
#explode(empty_as_null: true, keep_nulls: true) ⇒ Series
Returns a column with a separate row for every list element.
745 746 747 |
# File 'lib/polars/list_name_space.rb', line 745 def explode(empty_as_null: true, keep_nulls: true) super end |
#filter(predicate) ⇒ Series
Filter elements in each list by a boolean expression, returning a new Series of lists.
918 919 920 |
# File 'lib/polars/list_name_space.rb', line 918 def filter(predicate) super end |
#first ⇒ Series
Get the first value of the sublists.
508 509 510 |
# File 'lib/polars/list_name_space.rb', line 508 def first super end |
#gather(indices, null_on_oob: false) ⇒ Series
Take sublists by multiple indices.
The indices may be defined in a single column, or by sublists in another
column of dtype List.
427 428 429 430 431 432 |
# File 'lib/polars/list_name_space.rb', line 427 def gather( indices, null_on_oob: false ) super end |
#gather_every(n, offset = 0) ⇒ Series
Take every n-th value start from offset in sublists.
454 455 456 |
# File 'lib/polars/list_name_space.rb', line 454 def gather_every(n, offset = 0) super end |
#get(index, null_on_oob: false) ⇒ Series
Get the value by index in the sublists.
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.
397 398 399 |
# File 'lib/polars/list_name_space.rb', line 397 def get(index, null_on_oob: false) super end |
#head(n = 5) ⇒ Series
Slice the first n values of every sublist.
697 698 699 |
# File 'lib/polars/list_name_space.rb', line 697 def head(n = 5) super end |
#item ⇒ Series
Get the single value of the sublists.
This errors if the sublist length is not exactly one.
548 549 550 |
# File 'lib/polars/list_name_space.rb', line 548 def item super end |
#join(separator, ignore_nulls: true) ⇒ Series
Join all string items in a sublist and place a separator between them.
This errors if inner type of list != Utf8.
489 490 491 |
# File 'lib/polars/list_name_space.rb', line 489 def join(separator, ignore_nulls: true) super end |
#last ⇒ Series
Get the last value of the sublists.
527 528 529 |
# File 'lib/polars/list_name_space.rb', line 527 def last super end |
#len ⇒ Series
Get the length of the arrays as UInt32.
77 78 79 |
# File 'lib/polars/list_name_space.rb', line 77 def len super end |
#max ⇒ Series
Compute the max value of the arrays in the list.
165 166 167 |
# File 'lib/polars/list_name_space.rb', line 165 def max super end |
#mean ⇒ Series
Compute the mean value of the arrays in the list.
201 202 203 |
# File 'lib/polars/list_name_space.rb', line 201 def mean super end |
#median ⇒ Series
Compute the median value of the arrays in the list.
219 220 221 |
# File 'lib/polars/list_name_space.rb', line 219 def median super end |
#min ⇒ Series
Compute the min value of the arrays in the list.
183 184 185 |
# File 'lib/polars/list_name_space.rb', line 183 def min super end |
#n_unique ⇒ Series
Count the number of unique values in every sub-lists.
345 346 347 |
# File 'lib/polars/list_name_space.rb', line 345 def n_unique super end |
#reverse ⇒ Series
Reverse the arrays in the list.
306 307 308 |
# File 'lib/polars/list_name_space.rb', line 306 def reverse super end |
#sample(n: nil, fraction: nil, with_replacement: false, shuffle: false, seed: nil) ⇒ Series
Sample from this list.
129 130 131 |
# File 'lib/polars/list_name_space.rb', line 129 def sample(n: nil, fraction: nil, with_replacement: false, shuffle: false, seed: nil) super end |
#set_difference(other) ⇒ Series
Compute the SET DIFFERENCE between the elements in this list and the elements of other.
966 967 968 |
# File 'lib/polars/list_name_space.rb', line 966 def set_difference(other) super end |
#set_intersection(other) ⇒ Series
Compute the SET INTERSECTION between the elements in this list and the elements of other.
990 991 992 |
# File 'lib/polars/list_name_space.rb', line 990 def set_intersection(other) super end |
#set_symmetric_difference(other) ⇒ Series
Compute the SET SYMMETRIC DIFFERENCE between the elements in this list and the elements of other.
1014 1015 1016 |
# File 'lib/polars/list_name_space.rb', line 1014 def set_symmetric_difference(other) super end |
#set_union(other) ⇒ Series
Compute the SET UNION between the elements in this list and the elements of other.
942 943 944 |
# File 'lib/polars/list_name_space.rb', line 942 def set_union(other) super end |
#shift(n = 1) ⇒ Series
Shift values by the given period.
652 653 654 |
# File 'lib/polars/list_name_space.rb', line 652 def shift(n = 1) super end |
#slice(offset, length = nil) ⇒ Series
Slice every sublist.
676 677 678 |
# File 'lib/polars/list_name_space.rb', line 676 def slice(offset, length = nil) super end |
#sort(descending: false, nulls_last: false) ⇒ Series
Sort the arrays in the list.
288 289 290 |
# File 'lib/polars/list_name_space.rb', line 288 def sort(descending: false, nulls_last: false) super end |
#std(ddof: 1) ⇒ Series
Compute the std value of the arrays in the list.
237 238 239 |
# File 'lib/polars/list_name_space.rb', line 237 def std(ddof: 1) super end |
#sum ⇒ Series
Sum all the arrays in the list.
147 148 149 |
# File 'lib/polars/list_name_space.rb', line 147 def sum super end |
#tail(n = 5) ⇒ Series
Slice the last n values of every sublist.
718 719 720 |
# File 'lib/polars/list_name_space.rb', line 718 def tail(n = 5) super end |
#to_array(width) ⇒ Series
Convert a List column into an Array column with the same inner data type.
790 791 792 |
# File 'lib/polars/list_name_space.rb', line 790 def to_array(width) super end |
#to_struct(n_field_strategy: "first_non_null", fields: nil) ⇒ Series
Convert the series of type List to a series of type Struct.
829 830 831 832 833 834 835 836 837 838 839 840 |
# File 'lib/polars/list_name_space.rb', line 829 def to_struct(n_field_strategy: "first_non_null", fields: nil) if fields.is_a?(::Array) s = Utils.wrap_s(_s) return ( s.to_frame .select_seq(F.col(s.name).list.to_struct(fields: fields)) .to_series ) end Utils.wrap_s(_s.list_to_struct(n_field_strategy, fields)) end |
#unique(maintain_order: false) ⇒ Series
Get the unique/distinct values in the list.
327 328 329 |
# File 'lib/polars/list_name_space.rb', line 327 def unique(maintain_order: false) super end |
#var(ddof: 1) ⇒ Series
Compute the var value of the arrays in the list.
255 256 257 |
# File 'lib/polars/list_name_space.rb', line 255 def var(ddof: 1) super end |