Class: Polars::Expr
- Inherits:
-
Object
- Object
- Polars::Expr
- Defined in:
- lib/polars/expr.rb
Overview
Expressions that can be used in various contexts.
Direct Known Subclasses
Class Method Summary collapse
-
.deserialize(source) ⇒ Expr
Read a serialized expression from a file.
Instance Method Summary collapse
-
#! ⇒ Expr
(also: #~)
Performs boolean not.
-
#!=(other) ⇒ Expr
Not equal.
-
#%(other) ⇒ Expr
Returns the modulo.
-
#&(other) ⇒ Expr
Bitwise AND.
-
#*(other) ⇒ Expr
Performs multiplication.
-
#**(power) ⇒ Expr
Raises to the power of exponent.
-
#+(other) ⇒ Expr
Performs addition.
-
#-(other) ⇒ Expr
Performs subtraction.
-
#-@ ⇒ Expr
Performs negation.
-
#/(other) ⇒ Expr
Performs division.
-
#<(other) ⇒ Expr
Less than.
-
#<=(other) ⇒ Expr
Less than or equal.
-
#==(other) ⇒ Expr
Equal.
-
#>(other) ⇒ Expr
Greater than.
-
#>=(other) ⇒ Expr
Greater than or equal.
-
#^(other) ⇒ Expr
Bitwise XOR.
-
#_hash(seed = 0, seed_1 = nil, seed_2 = nil, seed_3 = nil) ⇒ Expr
Hash the elements in the selection.
-
#abs ⇒ Expr
Compute absolute values.
-
#add(other) ⇒ Expr
Method equivalent of addition operator
expr + other
. -
#agg_groups ⇒ Expr
Get the group indexes of the group by operation.
-
#alias(name) ⇒ Expr
Rename the output of an expression.
-
#all(drop_nulls: true) ⇒ Boolean
Check if all boolean values in a Boolean column are
true
. -
#and_(*others) ⇒ Expr
Method equivalent of bitwise "and" operator
expr & other & ...
. -
#any(drop_nulls: true) ⇒ Boolean
Check if any boolean value in a Boolean column is
true
. -
#append(other, upcast: true) ⇒ Expr
Append expressions.
-
#approx_n_unique ⇒ Expr
(also: #approx_unique)
Approx count unique values.
-
#arccos ⇒ Expr
Compute the element-wise value for the inverse cosine.
-
#arccosh ⇒ Expr
Compute the element-wise value for the inverse hyperbolic cosine.
-
#arcsin ⇒ Expr
Compute the element-wise value for the inverse sine.
-
#arcsinh ⇒ Expr
Compute the element-wise value for the inverse hyperbolic sine.
-
#arctan ⇒ Expr
Compute the element-wise value for the inverse tangent.
-
#arctanh ⇒ Expr
Compute the element-wise value for the inverse hyperbolic tangent.
-
#arg_max ⇒ Expr
Get the index of the maximal value.
-
#arg_min ⇒ Expr
Get the index of the minimal value.
-
#arg_sort(reverse: false, nulls_last: false) ⇒ Expr
Get the index values that would sort this column.
-
#arg_true ⇒ Expr
Return indices where expression evaluates
true
. -
#arg_unique ⇒ Expr
Get index of first unique value.
-
#argsort(reverse: false, nulls_last: false) ⇒ expr
Get the index values that would sort this column.
-
#arr ⇒ ArrayExpr
Create an object namespace of all array related methods.
-
#backward_fill(limit: nil) ⇒ Expr
Fill missing values with the next to be seen values.
-
#bin ⇒ BinaryExpr
Create an object namespace of all binary related methods.
-
#bitwise_and ⇒ Expr
Perform an aggregation of bitwise ANDs.
-
#bitwise_count_ones ⇒ Expr
Evaluate the number of set bits.
-
#bitwise_count_zeros ⇒ Expr
Evaluate the number of unset bits.
-
#bitwise_leading_ones ⇒ Expr
Evaluate the number most-significant set bits before seeing an unset bit.
-
#bitwise_leading_zeros ⇒ Expr
Evaluate the number most-significant unset bits before seeing a set bit.
-
#bitwise_or ⇒ Expr
Perform an aggregation of bitwise ORs.
-
#bitwise_trailing_ones ⇒ Expr
Evaluate the number least-significant set bits before seeing an unset bit.
-
#bitwise_trailing_zeros ⇒ Expr
Evaluate the number least-significant unset bits before seeing a set bit.
-
#bitwise_xor ⇒ Expr
Perform an aggregation of bitwise XORs.
-
#bottom_k(k: 5) ⇒ Expr
Return the
k
smallest elements. -
#bottom_k_by(by, k: 5, reverse: false) ⇒ Expr
Return the elements corresponding to the
k
smallest elements of theby
column(s). -
#cast(dtype, strict: true) ⇒ Expr
Cast between data types.
-
#cat ⇒ CatExpr
Create an object namespace of all categorical related methods.
-
#cbrt ⇒ Expr
Compute the cube root of the elements.
-
#ceil ⇒ Expr
Rounds up to the nearest integer value.
-
#clip(lower_bound = nil, upper_bound = nil) ⇒ Expr
Set values outside the given boundaries to the boundary value.
-
#clip_max(upper_bound) ⇒ Expr
Clip (limit) the values in an array to a
max
boundary. -
#clip_min(lower_bound) ⇒ Expr
Clip (limit) the values in an array to a
min
boundary. -
#cos ⇒ Expr
Compute the element-wise value for the cosine.
-
#cosh ⇒ Expr
Compute the element-wise value for the hyperbolic cosine.
-
#cot ⇒ Expr
Compute the element-wise value for the cotangent.
-
#count ⇒ Expr
Count the number of values in this expression.
-
#cum_count(reverse: false) ⇒ Expr
(also: #cumcount)
Get an array with the cumulative count computed at every element.
-
#cum_max(reverse: false) ⇒ Expr
(also: #cummax)
Get an array with the cumulative max computed at every element.
-
#cum_min(reverse: false) ⇒ Expr
(also: #cummin)
Get an array with the cumulative min computed at every element.
-
#cum_prod(reverse: false) ⇒ Expr
(also: #cumprod)
Get an array with the cumulative product computed at every element.
-
#cum_sum(reverse: false) ⇒ Expr
(also: #cumsum)
Get an array with the cumulative sum computed at every element.
-
#cumulative_eval(expr, min_periods: 1) ⇒ Expr
Run an expression over a sliding window that increases
1
slot every iteration. -
#cut(breaks, labels: nil, left_closed: false, include_breaks: false) ⇒ Expr
Bin continuous values into discrete categories.
-
#degrees ⇒ Expr
Convert from radians to degrees.
-
#diff(n: 1, null_behavior: "ignore") ⇒ Expr
Calculate the n-th discrete difference.
-
#dot(other) ⇒ Expr
Compute the dot/inner product between two Expressions.
-
#drop_nans ⇒ Expr
Drop floating point NaN values.
-
#drop_nulls ⇒ Expr
Drop null values.
-
#dt ⇒ DateTimeExpr
Create an object namespace of all datetime related methods.
-
#entropy(base: 2, normalize: true) ⇒ Expr
Computes the entropy.
-
#eq(other) ⇒ Expr
Method equivalent of equality operator
expr == other
. -
#eq_missing(other) ⇒ Expr
Method equivalent of equality operator
expr == other
wherenil == nil
. -
#ewm_mean(com: nil, span: nil, half_life: nil, alpha: nil, adjust: true, min_periods: 1, ignore_nulls: true) ⇒ Expr
Exponentially-weighted moving average.
-
#ewm_mean_by(by, half_life:) ⇒ Expr
Compute time-based exponentially weighted moving average.
-
#ewm_std(com: nil, span: nil, half_life: nil, alpha: nil, adjust: true, bias: false, min_periods: 1, ignore_nulls: true) ⇒ Expr
Exponentially-weighted moving standard deviation.
-
#ewm_var(com: nil, span: nil, half_life: nil, alpha: nil, adjust: true, bias: false, min_periods: 1, ignore_nulls: true) ⇒ Expr
Exponentially-weighted moving variance.
-
#exclude(columns, *more_columns) ⇒ Expr
Exclude certain columns from a wildcard/regex selection.
-
#exp ⇒ Expr
Compute the exponential, element-wise.
-
#explode ⇒ Expr
Explode a list or utf8 Series.
-
#extend_constant(value, n) ⇒ Expr
Extend the Series with given number of values.
-
#fill_nan(fill_value) ⇒ Expr
Fill floating point NaN value with a fill value.
-
#fill_null(value = nil, strategy: nil, limit: nil) ⇒ Expr
Fill null values using the specified value or strategy.
-
#filter(predicate) ⇒ Expr
Filter a single column.
-
#first ⇒ Expr
Get the first value.
-
#flatten ⇒ Expr
Explode a list or utf8 Series.
-
#floor ⇒ Expr
Rounds down to the nearest integer value.
-
#floordiv(other) ⇒ Expr
Method equivalent of integer division operator
expr // other
. -
#forward_fill(limit: nil) ⇒ Expr
Fill missing values with the latest seen values.
-
#gather(indices) ⇒ Expr
(also: #take)
Take values by index.
-
#gather_every(n, offset = 0) ⇒ Expr
(also: #take_every)
Take every nth value in the Series and return as a new Series.
-
#ge(other) ⇒ Expr
Method equivalent of "greater than or equal" operator
expr >= other
. -
#get(index) ⇒ Expr
Return a single value by index.
-
#gt(other) ⇒ Expr
Method equivalent of "greater than" operator
expr > other
. -
#has_nulls ⇒ Expr
Check whether the expression contains one or more null values.
-
#head(n = 10) ⇒ Expr
Get the first
n
rows. -
#hist(bins: nil, bin_count: nil, include_category: false, include_breakpoint: false) ⇒ Expr
Bin values into buckets and count their occurrences.
-
#implode ⇒ Expr
Aggregate to list.
-
#index_of(element) ⇒ Expr
Get the index of the first occurrence of a value, or
nil
if it's not found. -
#interpolate(method: "linear") ⇒ Expr
Fill nulls with linear interpolation over missing values.
-
#interpolate_by(by) ⇒ Expr
Fill null values using interpolation based on another column.
-
#is_between(lower_bound, upper_bound, closed: "both") ⇒ Expr
Check if this expression is between start and end.
-
#is_close(other, abs_tol: 0.0, rel_tol: 1e-09, nans_equal: false) ⇒ Expr
Check if this expression is close, i.e.
-
#is_duplicated ⇒ Expr
Get mask of duplicated values.
-
#is_finite ⇒ Expr
Returns a boolean Series indicating which values are finite.
-
#is_first_distinct ⇒ Expr
(also: #is_first)
Get a mask of the first unique value.
-
#is_in(other, nulls_equal: false) ⇒ Expr
(also: #in?)
Check if elements of this expression are present in the other Series.
-
#is_infinite ⇒ Expr
Returns a boolean Series indicating which values are infinite.
-
#is_last_distinct ⇒ Expr
Return a boolean mask indicating the last occurrence of each distinct value.
-
#is_nan ⇒ Expr
Returns a boolean Series indicating which values are NaN.
-
#is_not ⇒ Expr
(also: #not_)
Negate a boolean expression.
-
#is_not_nan ⇒ Expr
Returns a boolean Series indicating which values are not NaN.
-
#is_not_null ⇒ Expr
Returns a boolean Series indicating which values are not null.
-
#is_null ⇒ Expr
Returns a boolean Series indicating which values are null.
-
#is_unique ⇒ Expr
Get mask of unique values.
-
#keep_name ⇒ Expr
Keep the original root name of the expression.
-
#kurtosis(fisher: true, bias: true) ⇒ Expr
Compute the kurtosis (Fisher or Pearson) of a dataset.
-
#last ⇒ Expr
Get the last value.
-
#le(other) ⇒ Expr
Method equivalent of "less than or equal" operator
expr <= other
. -
#len ⇒ Expr
(also: #length)
Count the number of values in this expression.
-
#limit(n = 10) ⇒ Expr
Get the first
n
rows. -
#list ⇒ ListExpr
Create an object namespace of all list related methods.
-
#log(base = Math::E) ⇒ Expr
Compute the logarithm to a given base.
-
#log10 ⇒ Expr
Compute the base 10 logarithm of the input array, element-wise.
-
#log1p ⇒ Expr
Compute the natural logarithm of each element plus one.
-
#lower_bound ⇒ Expr
Calculate the lower bound.
-
#lt(other) ⇒ Expr
Method equivalent of "less than" operator
expr < other
. -
#map_alias(&f) ⇒ Expr
Rename the output of an expression by mapping a function over the root name.
-
#max ⇒ Expr
Get maximum value.
-
#mean ⇒ Expr
Get mean value.
-
#median ⇒ Expr
Get median value using linear interpolation.
-
#meta ⇒ MetaExpr
Create an object namespace of all meta related expression methods.
-
#min ⇒ Expr
Get minimum value.
-
#mod(other) ⇒ Expr
Method equivalent of modulus operator
expr % other
. -
#mode ⇒ Expr
Compute the most occurring value(s).
-
#mul(other) ⇒ Expr
Method equivalent of multiplication operator
expr * other
. -
#n_unique ⇒ Expr
Count unique values.
-
#name ⇒ NameExpr
Create an object namespace of all expressions that modify expression names.
-
#nan_max ⇒ Expr
Get maximum value, but propagate/poison encountered NaN values.
-
#nan_min ⇒ Expr
Get minimum value, but propagate/poison encountered NaN values.
-
#ne(other) ⇒ Expr
Method equivalent of inequality operator
expr != other
. -
#ne_missing(other) ⇒ Expr
Method equivalent of equality operator
expr != other
wherenil == nil
. -
#neg ⇒ Expr
Method equivalent of unary minus operator
-expr
. -
#null_count ⇒ Expr
Count null values.
-
#or_(*others) ⇒ Expr
Method equivalent of bitwise "or" operator
expr | other | ...
. -
#over(expr) ⇒ Expr
Apply window function over a subgroup.
-
#pct_change(n: 1) ⇒ Expr
Computes percentage change between values.
-
#peak_max ⇒ Expr
Get a boolean mask of the local maximum peaks.
-
#peak_min ⇒ Expr
Get a boolean mask of the local minimum peaks.
-
#pow(exponent) ⇒ Expr
Raise expression to the power of exponent.
-
#prefix(prefix) ⇒ Expr
Add a prefix to the root column name of the expression.
-
#product ⇒ Expr
Compute the product of an expression.
-
#qcut(quantiles, labels: nil, left_closed: false, allow_duplicates: false, include_breaks: false) ⇒ Expr
Bin continuous values into discrete categories based on their quantiles.
-
#quantile(quantile, interpolation: "nearest") ⇒ Expr
Get quantile value.
-
#radians ⇒ Expr
Convert from degrees to radians.
-
#rank(method: "average", reverse: false, seed: nil) ⇒ Expr
Assign ranks to data, dealing with ties appropriately.
-
#rechunk ⇒ Expr
Create a single chunk of memory for this Series.
-
#reinterpret(signed: false) ⇒ Expr
Reinterpret the underlying bits as a signed/unsigned integer.
-
#repeat_by(by) ⇒ Expr
Repeat the elements in this Series as specified in the given expression.
-
#replace(old, new = NO_DEFAULT, default: NO_DEFAULT, return_dtype: nil) ⇒ Expr
Replace values by different values.
-
#replace_strict(old, new = NO_DEFAULT, default: NO_DEFAULT, return_dtype: nil) ⇒ Expr
Replace all values by different values.
-
#reshape(dims) ⇒ Expr
Reshape this Expr to a flat Series or a Series of Lists.
-
#reverse ⇒ Expr
Reverse the selection.
-
#rle ⇒ Expr
Get the lengths of runs of identical values.
-
#rle_id ⇒ Expr
Map values to run IDs.
-
#rolling(index_column:, period:, offset: nil, closed: "right") ⇒ Expr
Create rolling groups based on a temporal or integer column.
-
#rolling_kurtosis(window_size, fisher: true, bias: true, min_samples: nil, center: false) ⇒ Expr
Compute a rolling kurtosis.
-
#rolling_max(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
Apply a rolling max (moving max) over the values in this array.
-
#rolling_max_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
Apply a rolling max based on another column.
-
#rolling_mean(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
Apply a rolling mean (moving mean) over the values in this array.
-
#rolling_mean_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
Apply a rolling mean based on another column.
-
#rolling_median(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
Compute a rolling median.
-
#rolling_median_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
Compute a rolling median based on another column.
-
#rolling_min(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
Apply a rolling min (moving min) over the values in this array.
-
#rolling_min_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
Apply a rolling min based on another column.
-
#rolling_quantile(quantile, interpolation: "nearest", window_size: 2, weights: nil, min_periods: nil, center: false) ⇒ Expr
Compute a rolling quantile.
-
#rolling_quantile_by(by, window_size, quantile:, interpolation: "nearest", min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
Compute a rolling quantile based on another column.
-
#rolling_skew(window_size, bias: true, min_samples: nil, center: false) ⇒ Expr
Compute a rolling skew.
-
#rolling_std(window_size, weights: nil, min_periods: nil, center: false, ddof: 1) ⇒ Expr
Compute a rolling standard deviation.
-
#rolling_std_by(by, window_size, min_periods: 1, closed: "right", ddof: 1, warn_if_unsorted: nil) ⇒ Expr
Compute a rolling standard deviation based on another column.
-
#rolling_sum(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
Apply a rolling sum (moving sum) over the values in this array.
-
#rolling_sum_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
Apply a rolling sum based on another column.
-
#rolling_var(window_size, weights: nil, min_periods: nil, center: false, ddof: 1) ⇒ Expr
Compute a rolling variance.
-
#rolling_var_by(by, window_size, min_periods: 1, closed: "right", ddof: 1, warn_if_unsorted: nil) ⇒ Expr
Compute a rolling variance based on another column.
-
#round(decimals = 0, mode: "half_to_even") ⇒ Expr
Round underlying floating point data by
decimals
digits. -
#round_sig_figs(digits) ⇒ Expr
Round to a number of significant figures.
-
#sample(frac: nil, with_replacement: true, shuffle: false, seed: nil, n: nil) ⇒ Expr
Sample from this expression.
-
#search_sorted(element, side: "any", descending: false) ⇒ Expr
Find indices where elements should be inserted to maintain order.
-
#set_sorted(descending: false) ⇒ Expr
Flags the expression as 'sorted'.
-
#shift(n = 1, fill_value: nil) ⇒ Expr
Shift the values by a given period.
-
#shift_and_fill(periods, fill_value) ⇒ Expr
Shift the values by a given period and fill the resulting null values.
-
#shrink_dtype ⇒ Expr
Shrink numeric columns to the minimal required datatype.
-
#shuffle(seed: nil) ⇒ Expr
Shuffle the contents of this expr.
-
#sign ⇒ Expr
Compute the element-wise indication of the sign.
-
#sin ⇒ Expr
Compute the element-wise value for the sine.
-
#sinh ⇒ Expr
Compute the element-wise value for the hyperbolic sine.
-
#skew(bias: true) ⇒ Expr
Compute the sample skewness of a data set.
-
#slice(offset, length = nil) ⇒ Expr
Get a slice of this expression.
-
#sort(reverse: false, nulls_last: false) ⇒ Expr
Sort this column.
-
#sort_by(by, *more_by, reverse: false, nulls_last: false, multithreaded: true, maintain_order: false) ⇒ Expr
Sort this column by the ordering of another column, or multiple other columns.
-
#sqrt ⇒ Expr
Compute the square root of the elements.
-
#std(ddof: 1) ⇒ Expr
Get standard deviation.
-
#str ⇒ StringExpr
Create an object namespace of all string related methods.
-
#struct ⇒ StructExpr
Create an object namespace of all struct related methods.
-
#sub(other) ⇒ Expr
Method equivalent of subtraction operator
expr - other
. -
#suffix(suffix) ⇒ Expr
Add a suffix to the root column name of the expression.
-
#sum ⇒ Expr
Get sum value.
-
#tail(n = 10) ⇒ Expr
Get the last
n
rows. -
#tan ⇒ Expr
Compute the element-wise value for the tangent.
-
#tanh ⇒ Expr
Compute the element-wise value for the hyperbolic tangent.
-
#to_physical ⇒ Expr
Cast to physical representation of the logical dtype.
-
#to_s ⇒ String
(also: #inspect)
Returns a string representing the Expr.
-
#top_k(k: 5) ⇒ Expr
Return the
k
largest elements. -
#top_k_by(by, k: 5, reverse: false) ⇒ Expr
Return the elements corresponding to the
k
largest elements of theby
column(s). -
#truediv(other) ⇒ Expr
Method equivalent of float division operator
expr / other
. -
#unique(maintain_order: false) ⇒ Expr
Get unique values of this expression.
-
#unique_counts ⇒ Expr
Return a count of the unique values in the order of appearance.
-
#upper_bound ⇒ Expr
Calculate the upper bound.
-
#value_counts(sort: false, parallel: false, name: nil, normalize: false) ⇒ Expr
Count all unique values and create a struct mapping value to count.
-
#var(ddof: 1) ⇒ Expr
Get variance.
-
#where(predicate) ⇒ Expr
Filter a single column.
-
#xor(other) ⇒ Expr
Method equivalent of bitwise exclusive-or operator
expr ^ other
. -
#|(other) ⇒ Expr
Bitwise OR.
Class Method Details
.deserialize(source) ⇒ Expr
This function uses marshaling if the logical plan contains Ruby UDFs, and as such inherits the security implications. Deserializing can execute arbitrary code, so it should only be attempted on trusted data.
Serialization is not stable across Polars versions: a LazyFrame serialized in one Polars version may not be deserializable in another Polars version.
Read a serialized expression from a file.
171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/polars/expr.rb', line 171 def self.deserialize(source) raise Todo unless RbExpr.respond_to?(:deserialize_binary) if Utils.pathlike?(source) source = Utils.normalize_filepath(source) end deserializer = RbExpr.method(:deserialize_binary) _from_rbexpr(deserializer.(source)) end |
Instance Method Details
#! ⇒ Expr Also known as: ~
Performs boolean not.
137 138 139 |
# File 'lib/polars/expr.rb', line 137 def ! is_not end |
#!=(other) ⇒ Expr
Not equal.
116 117 118 |
# File 'lib/polars/expr.rb', line 116 def !=(other) wrap_expr(_rbexpr.neq(_to_expr(other)._rbexpr)) end |
#%(other) ⇒ Expr
Returns the modulo.
80 81 82 |
# File 'lib/polars/expr.rb', line 80 def %(other) wrap_expr(_rbexpr % _to_rbexpr(other)) end |
#&(other) ⇒ Expr
Bitwise AND.
36 37 38 39 |
# File 'lib/polars/expr.rb', line 36 def &(other) other = Utils.parse_into_expression(other) wrap_expr(_rbexpr.and_(other)) end |
#*(other) ⇒ Expr
Performs multiplication.
66 67 68 |
# File 'lib/polars/expr.rb', line 66 def *(other) wrap_expr(_rbexpr * _to_rbexpr(other)) end |
#**(power) ⇒ Expr
Raises to the power of exponent.
87 88 89 90 |
# File 'lib/polars/expr.rb', line 87 def **(power) exponent = Utils.parse_into_expression(power) wrap_expr(_rbexpr.pow(exponent)) end |
#+(other) ⇒ Expr
Performs addition.
52 53 54 |
# File 'lib/polars/expr.rb', line 52 def +(other) wrap_expr(_rbexpr + _to_rbexpr(other)) end |
#-(other) ⇒ Expr
Performs subtraction.
59 60 61 |
# File 'lib/polars/expr.rb', line 59 def -(other) wrap_expr(_rbexpr - _to_rbexpr(other)) end |
#-@ ⇒ Expr
Performs negation.
145 146 147 |
# File 'lib/polars/expr.rb', line 145 def -@ wrap_expr(_rbexpr.neg) end |
#/(other) ⇒ Expr
Performs division.
73 74 75 |
# File 'lib/polars/expr.rb', line 73 def /(other) wrap_expr(_rbexpr / _to_rbexpr(other)) end |
#<(other) ⇒ Expr
Less than.
123 124 125 |
# File 'lib/polars/expr.rb', line 123 def <(other) wrap_expr(_rbexpr.lt(_to_expr(other)._rbexpr)) end |
#<=(other) ⇒ Expr
Less than or equal.
102 103 104 |
# File 'lib/polars/expr.rb', line 102 def <=(other) wrap_expr(_rbexpr.lt_eq(_to_expr(other)._rbexpr)) end |
#==(other) ⇒ Expr
Equal.
109 110 111 |
# File 'lib/polars/expr.rb', line 109 def ==(other) wrap_expr(_rbexpr.eq(_to_expr(other)._rbexpr)) end |
#>(other) ⇒ Expr
Greater than.
130 131 132 |
# File 'lib/polars/expr.rb', line 130 def >(other) wrap_expr(_rbexpr.gt(_to_expr(other)._rbexpr)) end |
#>=(other) ⇒ Expr
Greater than or equal.
95 96 97 |
# File 'lib/polars/expr.rb', line 95 def >=(other) wrap_expr(_rbexpr.gt_eq(_to_expr(other)._rbexpr)) end |
#^(other) ⇒ Expr
Bitwise XOR.
28 29 30 31 |
# File 'lib/polars/expr.rb', line 28 def ^(other) other = Utils.parse_into_expression(other) wrap_expr(_rbexpr.xor_(other)) end |
#_hash(seed = 0, seed_1 = nil, seed_2 = nil, seed_3 = nil) ⇒ Expr
Hash the elements in the selection.
The hash value is of type :u64
.
4516 4517 4518 4519 4520 4521 4522 |
# File 'lib/polars/expr.rb', line 4516 def _hash(seed = 0, seed_1 = nil, seed_2 = nil, seed_3 = nil) k0 = seed k1 = seed_1.nil? ? seed : seed_1 k2 = seed_2.nil? ? seed : seed_2 k3 = seed_3.nil? ? seed : seed_3 wrap_expr(_rbexpr._hash(k0, k1, k2, k3)) end |
#abs ⇒ Expr
Compute absolute values.
6453 6454 6455 |
# File 'lib/polars/expr.rb', line 6453 def abs wrap_expr(_rbexpr.abs) end |
#add(other) ⇒ Expr
Method equivalent of addition operator expr + other
.
4074 4075 4076 |
# File 'lib/polars/expr.rb', line 4074 def add(other) self + other end |
#agg_groups ⇒ Expr
Get the group indexes of the group by operation.
Should be used in aggregation context only.
808 809 810 |
# File 'lib/polars/expr.rb', line 808 def agg_groups wrap_expr(_rbexpr.agg_groups) end |
#alias(name) ⇒ Expr
Rename the output of an expression.
410 411 412 |
# File 'lib/polars/expr.rb', line 410 def alias(name) wrap_expr(_rbexpr._alias(name)) end |
#all(drop_nulls: true) ⇒ Boolean
Check if all boolean values in a Boolean column are true
.
This method is an expression - not to be confused with
Polars.all
which is a function to select all columns.
261 262 263 |
# File 'lib/polars/expr.rb', line 261 def all(drop_nulls: true) wrap_expr(_rbexpr.all(drop_nulls)) end |
#and_(*others) ⇒ Expr
Method equivalent of bitwise "and" operator expr & other & ...
.
3711 3712 3713 |
# File 'lib/polars/expr.rb', line 3711 def and_(*others) ([self] + others).reduce(:&) end |
#any(drop_nulls: true) ⇒ Boolean
Check if any boolean value in a Boolean column is true
.
236 237 238 |
# File 'lib/polars/expr.rb', line 236 def any(drop_nulls: true) wrap_expr(_rbexpr.any(drop_nulls)) end |
#append(other, upcast: true) ⇒ Expr
Append expressions.
This is done by adding the chunks of other
to this Series
.
920 921 922 923 |
# File 'lib/polars/expr.rb', line 920 def append(other, upcast: true) other = Utils.parse_into_expression(other) wrap_expr(_rbexpr.append(other, upcast)) end |
#approx_n_unique ⇒ Expr Also known as: approx_unique
Approx count unique values.
This is done using the HyperLogLog++ algorithm for cardinality estimation.
2544 2545 2546 |
# File 'lib/polars/expr.rb', line 2544 def approx_n_unique wrap_expr(_rbexpr.approx_n_unique) end |
#arccos ⇒ Expr
Compute the element-wise value for the inverse cosine.
6969 6970 6971 |
# File 'lib/polars/expr.rb', line 6969 def arccos wrap_expr(_rbexpr.arccos) end |
#arccosh ⇒ Expr
Compute the element-wise value for the inverse hyperbolic cosine.
7089 7090 7091 |
# File 'lib/polars/expr.rb', line 7089 def arccosh wrap_expr(_rbexpr.arccosh) end |
#arcsin ⇒ Expr
Compute the element-wise value for the inverse sine.
6949 6950 6951 |
# File 'lib/polars/expr.rb', line 6949 def arcsin wrap_expr(_rbexpr.arcsin) end |
#arcsinh ⇒ Expr
Compute the element-wise value for the inverse hyperbolic sine.
7069 7070 7071 |
# File 'lib/polars/expr.rb', line 7069 def arcsinh wrap_expr(_rbexpr.arcsinh) end |
#arctan ⇒ Expr
Compute the element-wise value for the inverse tangent.
6989 6990 6991 |
# File 'lib/polars/expr.rb', line 6989 def arctan wrap_expr(_rbexpr.arctan) end |
#arctanh ⇒ Expr
Compute the element-wise value for the inverse hyperbolic tangent.
7109 7110 7111 |
# File 'lib/polars/expr.rb', line 7109 def arctanh wrap_expr(_rbexpr.arctanh) end |
#arg_max ⇒ Expr
Get the index of the maximal value.
1794 1795 1796 |
# File 'lib/polars/expr.rb', line 1794 def arg_max wrap_expr(_rbexpr.arg_max) end |
#arg_min ⇒ Expr
Get the index of the minimal value.
1818 1819 1820 |
# File 'lib/polars/expr.rb', line 1818 def arg_min wrap_expr(_rbexpr.arg_min) end |
#arg_sort(reverse: false, nulls_last: false) ⇒ Expr
Get the index values that would sort this column.
1770 1771 1772 |
# File 'lib/polars/expr.rb', line 1770 def arg_sort(reverse: false, nulls_last: false) wrap_expr(_rbexpr.arg_sort(reverse, nulls_last)) end |
#arg_true ⇒ Expr
Modifies number of rows returned, so will fail in combination with other
expressions. Use as only expression in select
/ with_columns
.
Return indices where expression evaluates true
.
287 288 289 |
# File 'lib/polars/expr.rb', line 287 def arg_true wrap_expr(Plr.arg_where(_rbexpr)) end |
#arg_unique ⇒ Expr
Get index of first unique value.
2636 2637 2638 |
# File 'lib/polars/expr.rb', line 2636 def arg_unique wrap_expr(_rbexpr.arg_unique) end |
#argsort(reverse: false, nulls_last: false) ⇒ expr
Get the index values that would sort this column.
Alias for #arg_sort.
6486 6487 6488 |
# File 'lib/polars/expr.rb', line 6486 def argsort(reverse: false, nulls_last: false) arg_sort(reverse: reverse, nulls_last: nulls_last) end |
#arr ⇒ ArrayExpr
Create an object namespace of all array related methods.
8322 8323 8324 |
# File 'lib/polars/expr.rb', line 8322 def arr ArrayExpr.new(self) end |
#backward_fill(limit: nil) ⇒ Expr
Fill missing values with the next to be seen values.
2256 2257 2258 |
# File 'lib/polars/expr.rb', line 2256 def backward_fill(limit: nil) fill_null(strategy: "backward", limit: limit) end |
#bin ⇒ BinaryExpr
Create an object namespace of all binary related methods.
8329 8330 8331 |
# File 'lib/polars/expr.rb', line 8329 def bin BinaryExpr.new(self) end |
#bitwise_and ⇒ Expr
Perform an aggregation of bitwise ANDs.
8236 8237 8238 |
# File 'lib/polars/expr.rb', line 8236 def bitwise_and wrap_expr(_rbexpr.bitwise_and) end |
#bitwise_count_ones ⇒ Expr
Evaluate the number of set bits.
8165 8166 8167 |
# File 'lib/polars/expr.rb', line 8165 def bitwise_count_ones wrap_expr(_rbexpr.bitwise_count_ones) end |
#bitwise_count_zeros ⇒ Expr
Evaluate the number of unset bits.
8172 8173 8174 |
# File 'lib/polars/expr.rb', line 8172 def bitwise_count_zeros wrap_expr(_rbexpr.bitwise_count_zeros) end |
#bitwise_leading_ones ⇒ Expr
Evaluate the number most-significant set bits before seeing an unset bit.
8179 8180 8181 |
# File 'lib/polars/expr.rb', line 8179 def bitwise_leading_ones wrap_expr(_rbexpr.bitwise_leading_ones) end |
#bitwise_leading_zeros ⇒ Expr
Evaluate the number most-significant unset bits before seeing a set bit.
8186 8187 8188 |
# File 'lib/polars/expr.rb', line 8186 def bitwise_leading_zeros wrap_expr(_rbexpr.bitwise_leading_zeros) end |
#bitwise_or ⇒ Expr
Perform an aggregation of bitwise ORs.
8272 8273 8274 |
# File 'lib/polars/expr.rb', line 8272 def bitwise_or wrap_expr(_rbexpr.bitwise_or) end |
#bitwise_trailing_ones ⇒ Expr
Evaluate the number least-significant set bits before seeing an unset bit.
8193 8194 8195 |
# File 'lib/polars/expr.rb', line 8193 def bitwise_trailing_ones wrap_expr(_rbexpr.bitwise_trailing_ones) end |
#bitwise_trailing_zeros ⇒ Expr
Evaluate the number least-significant unset bits before seeing a set bit.
8200 8201 8202 |
# File 'lib/polars/expr.rb', line 8200 def bitwise_trailing_zeros wrap_expr(_rbexpr.bitwise_trailing_zeros) end |
#bitwise_xor ⇒ Expr
Perform an aggregation of bitwise XORs.
8308 8309 8310 |
# File 'lib/polars/expr.rb', line 8308 def bitwise_xor wrap_expr(_rbexpr.bitwise_xor) end |
#bottom_k(k: 5) ⇒ Expr
Return the k
smallest elements.
If 'reverse: true` the smallest elements will be given.
1632 1633 1634 1635 |
# File 'lib/polars/expr.rb', line 1632 def bottom_k(k: 5) k = Utils.parse_into_expression(k) wrap_expr(_rbexpr.bottom_k(k)) end |
#bottom_k_by(by, k: 5, reverse: false) ⇒ Expr
Return the elements corresponding to the k
smallest elements of the by
column(s).
Non-null elements are always preferred over null elements, regardless of
the value of reverse
. The output is not guaranteed to be in any
particular order, call :func:sort
after this function if you wish the
output to be sorted.
1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 |
# File 'lib/polars/expr.rb', line 1732 def bottom_k_by( by, k: 5, reverse: false ) k = Utils.parse_into_expression(k) by = Utils.parse_into_list_of_expressions(by) reverse = Utils.extend_bool(reverse, by.length, "reverse", "by") wrap_expr(_rbexpr.bottom_k_by(by, k, reverse)) end |
#cast(dtype, strict: true) ⇒ Expr
Cast between data types.
1373 1374 1375 1376 |
# File 'lib/polars/expr.rb', line 1373 def cast(dtype, strict: true) dtype = Utils.rb_type_to_dtype(dtype) wrap_expr(_rbexpr.cast(dtype, strict)) end |
#cat ⇒ CatExpr
Create an object namespace of all categorical related methods.
8336 8337 8338 |
# File 'lib/polars/expr.rb', line 8336 def cat CatExpr.new(self) end |
#cbrt ⇒ Expr
Compute the cube root of the elements.
331 332 333 |
# File 'lib/polars/expr.rb', line 331 def cbrt wrap_expr(_rbexpr.cbrt) end |
#ceil ⇒ Expr
Rounds up to the nearest integer value.
Only works on floating point Series.
1220 1221 1222 |
# File 'lib/polars/expr.rb', line 1220 def ceil wrap_expr(_rbexpr.ceil) end |
#clip(lower_bound = nil, upper_bound = nil) ⇒ Expr
Set values outside the given boundaries to the boundary value.
Only works for numeric and temporal columns. If you want to clip other data
types, consider writing a when-then-otherwise
expression.
6711 6712 6713 6714 6715 6716 6717 6718 6719 |
# File 'lib/polars/expr.rb', line 6711 def clip(lower_bound = nil, upper_bound = nil) if !lower_bound.nil? lower_bound = Utils.parse_into_expression(lower_bound) end if !upper_bound.nil? upper_bound = Utils.parse_into_expression(upper_bound) end wrap_expr(_rbexpr.clip(lower_bound, upper_bound)) end |
#clip_max(upper_bound) ⇒ Expr
Clip (limit) the values in an array to a max
boundary.
Only works for numerical types.
If you want to clip other dtypes, consider writing a "when, then, otherwise"
expression. See when
for more information.
6779 6780 6781 |
# File 'lib/polars/expr.rb', line 6779 def clip_max(upper_bound) clip(nil, upper_bound) end |
#clip_min(lower_bound) ⇒ Expr
Clip (limit) the values in an array to a min
boundary.
Only works for numerical types.
If you want to clip other dtypes, consider writing a "when, then, otherwise"
expression. See when
for more information.
6748 6749 6750 |
# File 'lib/polars/expr.rb', line 6748 def clip_min(lower_bound) clip(lower_bound, nil) end |
#cos ⇒ Expr
Compute the element-wise value for the cosine.
6889 6890 6891 |
# File 'lib/polars/expr.rb', line 6889 def cos wrap_expr(_rbexpr.cos) end |
#cosh ⇒ Expr
Compute the element-wise value for the hyperbolic cosine.
7029 7030 7031 |
# File 'lib/polars/expr.rb', line 7029 def cosh wrap_expr(_rbexpr.cosh) end |
#cot ⇒ Expr
Compute the element-wise value for the cotangent.
6929 6930 6931 |
# File 'lib/polars/expr.rb', line 6929 def cot wrap_expr(_rbexpr.cot) end |
#count ⇒ Expr
Count the number of values in this expression.
828 829 830 |
# File 'lib/polars/expr.rb', line 828 def count wrap_expr(_rbexpr.count) end |
#cum_count(reverse: false) ⇒ Expr Also known as: cumcount
Get an array with the cumulative count computed at every element.
Counting from 0 to len
1169 1170 1171 |
# File 'lib/polars/expr.rb', line 1169 def cum_count(reverse: false) wrap_expr(_rbexpr.cum_count(reverse)) end |
#cum_max(reverse: false) ⇒ Expr Also known as: cummax
Get an array with the cumulative max computed at every element.
1135 1136 1137 |
# File 'lib/polars/expr.rb', line 1135 def cum_max(reverse: false) wrap_expr(_rbexpr.cum_max(reverse)) end |
#cum_min(reverse: false) ⇒ Expr Also known as: cummin
Get an array with the cumulative min computed at every element.
1103 1104 1105 |
# File 'lib/polars/expr.rb', line 1103 def cum_min(reverse: false) wrap_expr(_rbexpr.cum_min(reverse)) end |
#cum_prod(reverse: false) ⇒ Expr Also known as: cumprod
Dtypes in :i8
, :u8
, :i16
, and :u16
are cast to
:i64
before summing to prevent overflow issues.
Get an array with the cumulative product computed at every element.
1071 1072 1073 |
# File 'lib/polars/expr.rb', line 1071 def cum_prod(reverse: false) wrap_expr(_rbexpr.cum_prod(reverse)) end |
#cum_sum(reverse: false) ⇒ Expr Also known as: cumsum
Dtypes in :i8
, :u8
, :i16
, and :u16
are cast to
:i64
before summing to prevent overflow issues.
Get an array with the cumulative sum computed at every element.
1035 1036 1037 |
# File 'lib/polars/expr.rb', line 1035 def cum_sum(reverse: false) wrap_expr(_rbexpr.cum_sum(reverse)) end |
#cumulative_eval(expr, min_periods: 1) ⇒ Expr
This functionality is experimental and may change without it being considered a breaking change.
This can be really slow as it can have O(n^2)
complexity. Don't use this
for operations that visit all elements.
Run an expression over a sliding window that increases 1
slot every iteration.
7713 7714 7715 7716 7717 |
# File 'lib/polars/expr.rb', line 7713 def cumulative_eval(expr, min_periods: 1) wrap_expr( _rbexpr.cumulative_eval(expr._rbexpr, min_periods) ) end |
#cut(breaks, labels: nil, left_closed: false, include_breaks: false) ⇒ Expr
Bin continuous values into discrete categories.
3146 3147 3148 |
# File 'lib/polars/expr.rb', line 3146 def cut(breaks, labels: nil, left_closed: false, include_breaks: false) wrap_expr(_rbexpr.cut(breaks, labels, left_closed, include_breaks)) end |
#degrees ⇒ Expr
Convert from radians to degrees.
7137 7138 7139 |
# File 'lib/polars/expr.rb', line 7137 def degrees wrap_expr(_rbexpr.degrees) end |
#diff(n: 1, null_behavior: "ignore") ⇒ Expr
Calculate the n-th discrete difference.
6581 6582 6583 6584 |
# File 'lib/polars/expr.rb', line 6581 def diff(n: 1, null_behavior: "ignore") n = Utils.parse_into_expression(n) wrap_expr(_rbexpr.diff(n, null_behavior)) end |
#dot(other) ⇒ Expr
Compute the dot/inner product between two Expressions.
1306 1307 1308 1309 |
# File 'lib/polars/expr.rb', line 1306 def dot(other) other = Utils.parse_into_expression(other, str_as_lit: false) wrap_expr(_rbexpr.dot(other)) end |
#drop_nans ⇒ Expr
Drop floating point NaN values.
1000 1001 1002 |
# File 'lib/polars/expr.rb', line 1000 def drop_nans wrap_expr(_rbexpr.drop_nans) end |
#drop_nulls ⇒ Expr
Drop null values.
973 974 975 |
# File 'lib/polars/expr.rb', line 973 def drop_nulls wrap_expr(_rbexpr.drop_nulls) end |
#dt ⇒ DateTimeExpr
Create an object namespace of all datetime related methods.
8343 8344 8345 |
# File 'lib/polars/expr.rb', line 8343 def dt DateTimeExpr.new(self) end |
#entropy(base: 2, normalize: true) ⇒ Expr
Computes the entropy.
Uses the formula -sum(pk * log(pk)
where pk
are discrete probabilities.
7669 7670 7671 |
# File 'lib/polars/expr.rb', line 7669 def entropy(base: 2, normalize: true) wrap_expr(_rbexpr.entropy(base, normalize)) end |
#eq(other) ⇒ Expr
Method equivalent of equality operator expr == other
.
3784 3785 3786 |
# File 'lib/polars/expr.rb', line 3784 def eq(other) self == other end |
#eq_missing(other) ⇒ Expr
Method equivalent of equality operator expr == other
where nil == nil
.
This differs from default eq
where null values are propagated.
3822 3823 3824 3825 |
# File 'lib/polars/expr.rb', line 3822 def eq_missing(other) other = Utils.parse_into_expression(other, str_as_lit: true) wrap_expr(_rbexpr.eq_missing(other)) end |
#ewm_mean(com: nil, span: nil, half_life: nil, alpha: nil, adjust: true, min_periods: 1, ignore_nulls: true) ⇒ Expr
Exponentially-weighted moving average.
7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 |
# File 'lib/polars/expr.rb', line 7317 def ewm_mean( com: nil, span: nil, half_life: nil, alpha: nil, adjust: true, min_periods: 1, ignore_nulls: true ) alpha = _prepare_alpha(com, span, half_life, alpha) wrap_expr(_rbexpr.ewm_mean(alpha, adjust, min_periods, ignore_nulls)) end |
#ewm_mean_by(by, half_life:) ⇒ Expr
Compute time-based exponentially weighted moving average.
7390 7391 7392 7393 7394 7395 7396 7397 |
# File 'lib/polars/expr.rb', line 7390 def ewm_mean_by( by, half_life: ) by = Utils.parse_into_expression(by) half_life = Utils.parse_as_duration_string(half_life) wrap_expr(_rbexpr.ewm_mean_by(by, half_life)) end |
#ewm_std(com: nil, span: nil, half_life: nil, alpha: nil, adjust: true, bias: false, min_periods: 1, ignore_nulls: true) ⇒ Expr
Exponentially-weighted moving standard deviation.
7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 |
# File 'lib/polars/expr.rb', line 7417 def ewm_std( com: nil, span: nil, half_life: nil, alpha: nil, adjust: true, bias: false, min_periods: 1, ignore_nulls: true ) alpha = _prepare_alpha(com, span, half_life, alpha) wrap_expr(_rbexpr.ewm_std(alpha, adjust, bias, min_periods, ignore_nulls)) end |
#ewm_var(com: nil, span: nil, half_life: nil, alpha: nil, adjust: true, bias: false, min_periods: 1, ignore_nulls: true) ⇒ Expr
Exponentially-weighted moving variance.
7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 |
# File 'lib/polars/expr.rb', line 7449 def ewm_var( com: nil, span: nil, half_life: nil, alpha: nil, adjust: true, bias: false, min_periods: 1, ignore_nulls: true ) alpha = _prepare_alpha(com, span, half_life, alpha) wrap_expr(_rbexpr.ewm_var(alpha, adjust, bias, min_periods, ignore_nulls)) end |
#exclude(columns, *more_columns) ⇒ Expr
Exclude certain columns from a wildcard/regex selection.
You may also use regexes in the exclude list. They must start with ^
and end
with $
.
448 449 450 |
# File 'lib/polars/expr.rb', line 448 def exclude(columns, *more_columns) .as_selector.exclude(columns, *more_columns).as_expr end |
#exp ⇒ Expr
Compute the exponential, element-wise.
375 376 377 |
# File 'lib/polars/expr.rb', line 375 def exp wrap_expr(_rbexpr.exp) end |
#explode ⇒ Expr
Explode a list or utf8 Series.
This means that every item is expanded to a new row.
3569 3570 3571 |
# File 'lib/polars/expr.rb', line 3569 def explode wrap_expr(_rbexpr.explode) end |
#extend_constant(value, n) ⇒ Expr
Extend the Series with given number of values.
7489 7490 7491 7492 7493 |
# File 'lib/polars/expr.rb', line 7489 def extend_constant(value, n) value = Utils.parse_into_expression(value, str_as_lit: true) n = Utils.parse_into_expression(n) wrap_expr(_rbexpr.extend_constant(value, n)) end |
#fill_nan(fill_value) ⇒ Expr
Fill floating point NaN value with a fill value.
2195 2196 2197 2198 |
# File 'lib/polars/expr.rb', line 2195 def fill_nan(fill_value) fill_value = Utils.parse_into_expression(fill_value, str_as_lit: true) wrap_expr(_rbexpr.fill_nan(fill_value)) end |
#fill_null(value = nil, strategy: nil, limit: nil) ⇒ Expr
Fill null values using the specified value or strategy.
To interpolate over null values see interpolate.
2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 |
# File 'lib/polars/expr.rb', line 2155 def fill_null(value = nil, strategy: nil, limit: nil) if !value.nil? && !strategy.nil? raise ArgumentError, "cannot specify both 'value' and 'strategy'." elsif value.nil? && strategy.nil? raise ArgumentError, "must specify either a fill 'value' or 'strategy'" elsif ["forward", "backward"].include?(strategy) && !limit.nil? raise ArgumentError, "can only specify 'limit' when strategy is set to 'backward' or 'forward'" end if !value.nil? value = Utils.parse_into_expression(value, str_as_lit: true) wrap_expr(_rbexpr.fill_null(value)) else wrap_expr(_rbexpr.fill_null_with_strategy(strategy, limit)) end end |
#filter(predicate) ⇒ Expr
Filter a single column.
Mostly useful in an aggregation context. If you want to filter on a DataFrame
level, use LazyFrame#filter
.
3329 3330 3331 |
# File 'lib/polars/expr.rb', line 3329 def filter(predicate) wrap_expr(_rbexpr.filter(predicate._rbexpr)) end |
#first ⇒ Expr
Get the first value.
2684 2685 2686 |
# File 'lib/polars/expr.rb', line 2684 def first wrap_expr(_rbexpr.first) end |
#flatten ⇒ Expr
Explode a list or utf8 Series. This means that every item is expanded to a new row.
Alias for #explode.
3542 3543 3544 |
# File 'lib/polars/expr.rb', line 3542 def flatten wrap_expr(_rbexpr.explode) end |
#floor ⇒ Expr
Rounds down to the nearest integer value.
Only works on floating point Series.
1195 1196 1197 |
# File 'lib/polars/expr.rb', line 1195 def floor wrap_expr(_rbexpr.floor) end |
#floordiv(other) ⇒ Expr
Method equivalent of integer division operator expr // other
.
4104 4105 4106 |
# File 'lib/polars/expr.rb', line 4104 def floordiv(other) wrap_expr(_rbexpr.floordiv(_to_rbexpr(other))) end |
#forward_fill(limit: nil) ⇒ Expr
Fill missing values with the latest seen values.
2226 2227 2228 |
# File 'lib/polars/expr.rb', line 2226 def forward_fill(limit: nil) fill_null(strategy: "forward", limit: limit) end |
#gather(indices) ⇒ Expr Also known as: take
Take values by index.
1987 1988 1989 1990 1991 1992 1993 1994 |
# File 'lib/polars/expr.rb', line 1987 def gather(indices) if indices.is_a?(::Array) indices_lit = Polars.lit(Series.new("", indices, dtype: :u32))._rbexpr else indices_lit = Utils.parse_into_expression(indices, str_as_lit: false) end wrap_expr(_rbexpr.gather(indices_lit)) end |
#gather_every(n, offset = 0) ⇒ Expr Also known as: take_every
Take every nth value in the Series and return as a new Series.
3591 3592 3593 |
# File 'lib/polars/expr.rb', line 3591 def gather_every(n, offset = 0) wrap_expr(_rbexpr.gather_every(n, offset)) end |
#ge(other) ⇒ Expr
Method equivalent of "greater than or equal" operator expr >= other
.
3856 3857 3858 |
# File 'lib/polars/expr.rb', line 3856 def ge(other) self >= other end |
#get(index) ⇒ Expr
Return a single value by index.
2029 2030 2031 2032 |
# File 'lib/polars/expr.rb', line 2029 def get(index) index_lit = Utils.parse_into_expression(index) wrap_expr(_rbexpr.get(index_lit)) end |
#gt(other) ⇒ Expr
Method equivalent of "greater than" operator expr > other
.
3889 3890 3891 |
# File 'lib/polars/expr.rb', line 3889 def gt(other) self > other end |
#has_nulls ⇒ Expr
Check whether the expression contains one or more null values.
2596 2597 2598 |
# File 'lib/polars/expr.rb', line 2596 def has_nulls null_count > 0 end |
#head(n = 10) ⇒ Expr
Get the first n
rows.
3617 3618 3619 |
# File 'lib/polars/expr.rb', line 3617 def head(n = 10) wrap_expr(_rbexpr.head(n)) end |
#hist(bins: nil, bin_count: nil, include_category: false, include_breakpoint: false) ⇒ Expr
This functionality is considered unstable. It may be changed at any point without it being considered a breaking change.
Bin values into buckets and count their occurrences.
7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 |
# File 'lib/polars/expr.rb', line 7832 def hist( bins: nil, bin_count: nil, include_category: false, include_breakpoint: false ) if !bins.nil? if bins.is_a?(::Array) bins = Polars::Series.new(bins) end bins = Utils.parse_into_expression(bins) end wrap_expr( _rbexpr.hist(bins, bin_count, include_category, include_breakpoint) ) end |
#implode ⇒ Expr
Aggregate to list.
7769 7770 7771 |
# File 'lib/polars/expr.rb', line 7769 def implode wrap_expr(_rbexpr.implode) end |
#index_of(element) ⇒ Expr
Get the index of the first occurrence of a value, or nil
if it's not found.
1847 1848 1849 1850 |
# File 'lib/polars/expr.rb', line 1847 def index_of(element) element = Utils.parse_into_expression(element, str_as_lit: true) wrap_expr(_rbexpr.index_of(element)) end |
#interpolate(method: "linear") ⇒ Expr
Fill nulls with linear interpolation over missing values.
Can also be used to regrid data to a new grid - see examples below.
4617 4618 4619 |
# File 'lib/polars/expr.rb', line 4617 def interpolate(method: "linear") wrap_expr(_rbexpr.interpolate(method)) end |
#interpolate_by(by) ⇒ Expr
Fill null values using interpolation based on another column.
4647 4648 4649 4650 |
# File 'lib/polars/expr.rb', line 4647 def interpolate_by(by) by = Utils.parse_into_expression(by) wrap_expr(_rbexpr.interpolate_by(by)) end |
#is_between(lower_bound, upper_bound, closed: "both") ⇒ Expr
Check if this expression is between start and end.
4436 4437 4438 4439 4440 4441 4442 4443 |
# File 'lib/polars/expr.rb', line 4436 def is_between(lower_bound, upper_bound, closed: "both") lower_bound = Utils.parse_into_expression(lower_bound) upper_bound = Utils.parse_into_expression(upper_bound) wrap_expr( _rbexpr.is_between(lower_bound, upper_bound, closed) ) end |
#is_close(other, abs_tol: 0.0, rel_tol: 1e-09, nans_equal: false) ⇒ Expr
Check if this expression is close, i.e. almost equal, to the other expression.
4472 4473 4474 4475 4476 4477 4478 4479 4480 |
# File 'lib/polars/expr.rb', line 4472 def is_close( other, abs_tol: 0.0, rel_tol: 1e-09, nans_equal: false ) other = Utils.parse_into_expression(other) wrap_expr(_rbexpr.is_close(other, abs_tol, rel_tol, nans_equal)) end |
#is_duplicated ⇒ Expr
Get mask of duplicated values.
2968 2969 2970 |
# File 'lib/polars/expr.rb', line 2968 def is_duplicated wrap_expr(_rbexpr.is_duplicated) end |
#is_finite ⇒ Expr
Returns a boolean Series indicating which values are finite.
681 682 683 |
# File 'lib/polars/expr.rb', line 681 def is_finite wrap_expr(_rbexpr.is_finite) end |
#is_first_distinct ⇒ Expr Also known as: is_first
Get a mask of the first unique value.
2921 2922 2923 |
# File 'lib/polars/expr.rb', line 2921 def is_first_distinct wrap_expr(_rbexpr.is_first_distinct) end |
#is_in(other, nulls_equal: false) ⇒ Expr Also known as: in?
Check if elements of this expression are present in the other Series.
4329 4330 4331 4332 |
# File 'lib/polars/expr.rb', line 4329 def is_in(other, nulls_equal: false) other = Utils.parse_into_expression(other) wrap_expr(_rbexpr.is_in(other, nulls_equal)) end |
#is_infinite ⇒ Expr
Returns a boolean Series indicating which values are infinite.
707 708 709 |
# File 'lib/polars/expr.rb', line 707 def is_infinite wrap_expr(_rbexpr.is_infinite) end |
#is_last_distinct ⇒ Expr
Return a boolean mask indicating the last occurrence of each distinct value.
2946 2947 2948 |
# File 'lib/polars/expr.rb', line 2946 def is_last_distinct wrap_expr(_rbexpr.is_last_distinct) end |
#is_nan ⇒ Expr
Floating point NaN
(Not A Number) should not be confused
with missing data represented as nil
.
Returns a boolean Series indicating which values are NaN.
740 741 742 |
# File 'lib/polars/expr.rb', line 740 def is_nan wrap_expr(_rbexpr.is_nan) end |
#is_not ⇒ Expr Also known as: not_
Negate a boolean expression.
596 597 598 |
# File 'lib/polars/expr.rb', line 596 def is_not wrap_expr(_rbexpr.not_) end |
#is_not_nan ⇒ Expr
Floating point NaN
(Not A Number) should not be confused
with missing data represented as nil
.
Returns a boolean Series indicating which values are not NaN.
773 774 775 |
# File 'lib/polars/expr.rb', line 773 def is_not_nan wrap_expr(_rbexpr.is_not_nan) end |
#is_not_null ⇒ Expr
Returns a boolean Series indicating which values are not null.
655 656 657 |
# File 'lib/polars/expr.rb', line 655 def is_not_null wrap_expr(_rbexpr.is_not_null) end |
#is_null ⇒ Expr
Returns a boolean Series indicating which values are null.
626 627 628 |
# File 'lib/polars/expr.rb', line 626 def is_null wrap_expr(_rbexpr.is_null) end |
#is_unique ⇒ Expr
Get mask of unique values.
2893 2894 2895 |
# File 'lib/polars/expr.rb', line 2893 def is_unique wrap_expr(_rbexpr.is_unique) end |
#keep_name ⇒ Expr
Keep the original root name of the expression.
474 475 476 |
# File 'lib/polars/expr.rb', line 474 def keep_name name.keep end |
#kurtosis(fisher: true, bias: true) ⇒ Expr
Compute the kurtosis (Fisher or Pearson) of a dataset.
Kurtosis is the fourth central moment divided by the square of the variance. If Fisher's definition is used, then 3.0 is subtracted from the result to give 0.0 for a normal distribution. If bias is False then the kurtosis is calculated using k statistics to eliminate bias coming from biased moment estimators
6680 6681 6682 |
# File 'lib/polars/expr.rb', line 6680 def kurtosis(fisher: true, bias: true) wrap_expr(_rbexpr.kurtosis(fisher, bias)) end |
#last ⇒ Expr
Get the last value.
2704 2705 2706 |
# File 'lib/polars/expr.rb', line 2704 def last wrap_expr(_rbexpr.last) end |
#le(other) ⇒ Expr
Method equivalent of "less than or equal" operator expr <= other
.
3922 3923 3924 |
# File 'lib/polars/expr.rb', line 3922 def le(other) self <= other end |
#len ⇒ Expr Also known as: length
Count the number of values in this expression.
848 849 850 |
# File 'lib/polars/expr.rb', line 848 def len wrap_expr(_rbexpr.len) end |
#limit(n = 10) ⇒ Expr
Get the first n
rows.
Alias for #head.
3669 3670 3671 |
# File 'lib/polars/expr.rb', line 3669 def limit(n = 10) head(n) end |
#list ⇒ ListExpr
Create an object namespace of all list related methods.
8315 8316 8317 |
# File 'lib/polars/expr.rb', line 8315 def list ListExpr.new(self) end |
#log(base = Math::E) ⇒ Expr
Compute the logarithm to a given base.
7605 7606 7607 7608 |
# File 'lib/polars/expr.rb', line 7605 def log(base = Math::E) base_rbexpr = Utils.parse_into_expression(base) wrap_expr(_rbexpr.log(base_rbexpr)) end |
#log10 ⇒ Expr
Compute the base 10 logarithm of the input array, element-wise.
353 354 355 |
# File 'lib/polars/expr.rb', line 353 def log10 log(10) end |
#log1p ⇒ Expr
Compute the natural logarithm of each element plus one.
This computes log(1 + x)
but is more numerically stable for x
close to zero.
7630 7631 7632 |
# File 'lib/polars/expr.rb', line 7630 def log1p wrap_expr(_rbexpr.log1p) end |
#lower_bound ⇒ Expr
Calculate the lower bound.
Returns a unit Series with the lowest value possible for the dtype of this expression.
6802 6803 6804 |
# File 'lib/polars/expr.rb', line 6802 def lower_bound wrap_expr(_rbexpr.lower_bound) end |
#lt(other) ⇒ Expr
Method equivalent of "less than" operator expr < other
.
3955 3956 3957 |
# File 'lib/polars/expr.rb', line 3955 def lt(other) self < other end |
#map_alias(&f) ⇒ Expr
Rename the output of an expression by mapping a function over the root name.
556 557 558 |
# File 'lib/polars/expr.rb', line 556 def map_alias(&f) name.map(&f) end |
#max ⇒ Expr
Get maximum value.
2358 2359 2360 |
# File 'lib/polars/expr.rb', line 2358 def max wrap_expr(_rbexpr.max) end |
#mean ⇒ Expr
Get mean value.
2462 2463 2464 |
# File 'lib/polars/expr.rb', line 2462 def mean wrap_expr(_rbexpr.mean) end |
#median ⇒ Expr
Get median value using linear interpolation.
2482 2483 2484 |
# File 'lib/polars/expr.rb', line 2482 def median wrap_expr(_rbexpr.median) end |
#meta ⇒ MetaExpr
Create an object namespace of all meta related expression methods.
8350 8351 8352 |
# File 'lib/polars/expr.rb', line 8350 def MetaExpr.new(self) end |
#min ⇒ Expr
Get minimum value.
2378 2379 2380 |
# File 'lib/polars/expr.rb', line 2378 def min wrap_expr(_rbexpr.min) end |
#mod(other) ⇒ Expr
Method equivalent of modulus operator expr % other
.
4131 4132 4133 |
# File 'lib/polars/expr.rb', line 4131 def mod(other) self % other end |
#mode ⇒ Expr
Compute the most occurring value(s).
Can return multiple Values.
1335 1336 1337 |
# File 'lib/polars/expr.rb', line 1335 def mode wrap_expr(_rbexpr.mode) end |
#mul(other) ⇒ Expr
Method equivalent of multiplication operator expr * other
.
4161 4162 4163 |
# File 'lib/polars/expr.rb', line 4161 def mul(other) self * other end |
#n_unique ⇒ Expr
Count unique values.
2522 2523 2524 |
# File 'lib/polars/expr.rb', line 2522 def n_unique wrap_expr(_rbexpr.n_unique) end |
#name ⇒ NameExpr
Create an object namespace of all expressions that modify expression names.
8357 8358 8359 |
# File 'lib/polars/expr.rb', line 8357 def name NameExpr.new(self) end |
#nan_max ⇒ Expr
Get maximum value, but propagate/poison encountered NaN values.
2398 2399 2400 |
# File 'lib/polars/expr.rb', line 2398 def nan_max wrap_expr(_rbexpr.nan_max) end |
#nan_min ⇒ Expr
Get minimum value, but propagate/poison encountered NaN values.
2418 2419 2420 |
# File 'lib/polars/expr.rb', line 2418 def nan_min wrap_expr(_rbexpr.nan_min) end |
#ne(other) ⇒ Expr
Method equivalent of inequality operator expr != other
.
3988 3989 3990 |
# File 'lib/polars/expr.rb', line 3988 def ne(other) self != other end |
#ne_missing(other) ⇒ Expr
Method equivalent of equality operator expr != other
where nil == nil
.
This differs from default ne
where null values are propagated.
4026 4027 4028 4029 |
# File 'lib/polars/expr.rb', line 4026 def ne_missing(other) other = Utils.parse_into_expression(other, str_as_lit: true) wrap_expr(_rbexpr.neq_missing(other)) end |
#neg ⇒ Expr
Method equivalent of unary minus operator -expr
.
4214 4215 4216 |
# File 'lib/polars/expr.rb', line 4214 def neg -self end |
#null_count ⇒ Expr
Count null values.
2570 2571 2572 |
# File 'lib/polars/expr.rb', line 2570 def null_count wrap_expr(_rbexpr.null_count) end |
#or_(*others) ⇒ Expr
Method equivalent of bitwise "or" operator expr | other | ...
.
3752 3753 3754 |
# File 'lib/polars/expr.rb', line 3752 def or_(*others) ([self] + others).reduce(:|) end |
#over(expr) ⇒ Expr
Apply window function over a subgroup.
This is similar to a group by + aggregation + self join. Or similar to window functions in Postgres.
2767 2768 2769 2770 |
# File 'lib/polars/expr.rb', line 2767 def over(expr) rbexprs = Utils.parse_into_list_of_expressions(expr) wrap_expr(_rbexpr.over(rbexprs)) end |
#pct_change(n: 1) ⇒ Expr
Computes percentage change between values.
Percentage change (as fraction) between current element and most-recent
non-null element at least n
period(s) before the current element.
Computes the change from the previous row by default.
6618 6619 6620 6621 |
# File 'lib/polars/expr.rb', line 6618 def pct_change(n: 1) n = Utils.parse_into_expression(n) wrap_expr(_rbexpr.pct_change(n)) end |
#peak_max ⇒ Expr
Get a boolean mask of the local maximum peaks.
2992 2993 2994 |
# File 'lib/polars/expr.rb', line 2992 def peak_max wrap_expr(_rbexpr.peak_max) end |
#peak_min ⇒ Expr
Get a boolean mask of the local minimum peaks.
3016 3017 3018 |
# File 'lib/polars/expr.rb', line 3016 def peak_min wrap_expr(_rbexpr.peak_min) end |
#pow(exponent) ⇒ Expr
Raise expression to the power of exponent.
4272 4273 4274 |
# File 'lib/polars/expr.rb', line 4272 def pow(exponent) self**exponent end |
#prefix(prefix) ⇒ Expr
Add a prefix to the root column name of the expression.
501 502 503 |
# File 'lib/polars/expr.rb', line 501 def prefix(prefix) name.prefix(prefix) end |
#product ⇒ Expr
Compute the product of an expression.
2502 2503 2504 |
# File 'lib/polars/expr.rb', line 2502 def product wrap_expr(_rbexpr.product) end |
#qcut(quantiles, labels: nil, left_closed: false, allow_duplicates: false, include_breaks: false) ⇒ Expr
Bin continuous values into discrete categories based on their quantiles.
3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 |
# File 'lib/polars/expr.rb', line 3227 def qcut(quantiles, labels: nil, left_closed: false, allow_duplicates: false, include_breaks: false) if quantiles.is_a?(Integer) rbexpr = _rbexpr.qcut_uniform( quantiles, labels, left_closed, allow_duplicates, include_breaks ) else rbexpr = _rbexpr.qcut( quantiles, labels, left_closed, allow_duplicates, include_breaks ) end wrap_expr(rbexpr) end |
#quantile(quantile, interpolation: "nearest") ⇒ Expr
Get quantile value.
3089 3090 3091 3092 |
# File 'lib/polars/expr.rb', line 3089 def quantile(quantile, interpolation: "nearest") quantile = Utils.parse_into_expression(quantile, str_as_lit: false) wrap_expr(_rbexpr.quantile(quantile, interpolation)) end |
#radians ⇒ Expr
Convert from degrees to radians.
7165 7166 7167 |
# File 'lib/polars/expr.rb', line 7165 def radians wrap_expr(_rbexpr.radians) end |
#rank(method: "average", reverse: false, seed: nil) ⇒ Expr
Assign ranks to data, dealing with ties appropriately.
6550 6551 6552 |
# File 'lib/polars/expr.rb', line 6550 def rank(method: "average", reverse: false, seed: nil) wrap_expr(_rbexpr.rank(method, reverse, seed)) end |
#rechunk ⇒ Expr
Create a single chunk of memory for this Series.
946 947 948 |
# File 'lib/polars/expr.rb', line 946 def rechunk wrap_expr(_rbexpr.rechunk) end |
#reinterpret(signed: false) ⇒ Expr
Reinterpret the underlying bits as a signed/unsigned integer.
This operation is only allowed for 64bit integers. For lower bits integers, you can safely use that cast operation.
4554 4555 4556 |
# File 'lib/polars/expr.rb', line 4554 def reinterpret(signed: false) wrap_expr(_rbexpr.reinterpret(signed)) end |
#repeat_by(by) ⇒ Expr
Repeat the elements in this Series as specified in the given expression.
The repeated elements are expanded into a List
.
4365 4366 4367 4368 |
# File 'lib/polars/expr.rb', line 4365 def repeat_by(by) by = Utils.parse_into_expression(by, str_as_lit: false) wrap_expr(_rbexpr.repeat_by(by)) end |
#replace(old, new = NO_DEFAULT, default: NO_DEFAULT, return_dtype: nil) ⇒ Expr
Replace values by different values.
7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 |
# File 'lib/polars/expr.rb', line 7985 def replace(old, new = NO_DEFAULT, default: NO_DEFAULT, return_dtype: nil) if !default.eql?(NO_DEFAULT) return replace_strict(old, new, default: default, return_dtype: return_dtype) end if new.eql?(NO_DEFAULT) && old.is_a?(Hash) new = Series.new(old.values) old = Series.new(old.keys) else if old.is_a?(::Array) old = Series.new(old) end if new.is_a?(::Array) new = Series.new(new) end end old = Utils.parse_into_expression(old, str_as_lit: true) new = Utils.parse_into_expression(new, str_as_lit: true) result = wrap_expr(_rbexpr.replace(old, new)) if !return_dtype.nil? result = result.cast(return_dtype) end result end |
#replace_strict(old, new = NO_DEFAULT, default: NO_DEFAULT, return_dtype: nil) ⇒ Expr
The global string cache must be enabled when replacing categorical values.
Replace all values by different values.
8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 |
# File 'lib/polars/expr.rb', line 8141 def replace_strict( old, new = NO_DEFAULT, default: NO_DEFAULT, return_dtype: nil ) if new.eql?(NO_DEFAULT) && old.is_a?(Hash) new = Series.new(old.values) old = Series.new(old.keys) end old = Utils.parse_into_expression(old, str_as_lit: true, list_as_series: true) new = Utils.parse_into_expression(new, str_as_lit: true, list_as_series: true) default = default.eql?(NO_DEFAULT) ? nil : Utils.parse_into_expression(default, str_as_lit: true) wrap_expr( _rbexpr.replace_strict(old, new, default, return_dtype) ) end |
#reshape(dims) ⇒ Expr
Reshape this Expr to a flat Series or a Series of Lists.
7211 7212 7213 |
# File 'lib/polars/expr.rb', line 7211 def reshape(dims) wrap_expr(_rbexpr.reshape(dims)) end |
#reverse ⇒ Expr
Reverse the selection.
2292 2293 2294 |
# File 'lib/polars/expr.rb', line 2292 def reverse wrap_expr(_rbexpr.reverse) end |
#rle ⇒ Expr
Get the lengths of runs of identical values.
3262 3263 3264 |
# File 'lib/polars/expr.rb', line 3262 def rle wrap_expr(_rbexpr.rle) end |
#rle_id ⇒ Expr
Map values to run IDs.
Similar to RLE, but it maps each value to an ID corresponding to the run into which it falls. This is especially useful when you want to define groups by runs of identical values rather than the values themselves.
3290 3291 3292 |
# File 'lib/polars/expr.rb', line 3290 def rle_id wrap_expr(_rbexpr.rle_id) end |
#rolling(index_column:, period:, offset: nil, closed: "right") ⇒ Expr
Create rolling groups based on a temporal or integer column.
If you have a time series <t_0, t_1, ..., t_n>
, then by default the
windows created will be
- (t_0 - period, t_0]
- (t_1 - period, t_1]
- ...
- (t_n - period, t_n]
whereas if you pass a non-default offset
, then the windows will be
- (t_0 + offset, t_0 + offset + period]
- (t_1 + offset, t_1 + offset + period]
- ...
- (t_n + offset, t_n + offset + period]
The period
and offset
arguments are created either from a timedelta, or
by using the following string language:
- 1ns (1 nanosecond)
- 1us (1 microsecond)
- 1ms (1 millisecond)
- 1s (1 second)
- 1m (1 minute)
- 1h (1 hour)
- 1d (1 calendar day)
- 1w (1 calendar week)
- 1mo (1 calendar month)
- 1q (1 calendar quarter)
- 1y (1 calendar year)
- 1i (1 index count)
Or combine them: "3d12h4m25s" # 3 days, 12 hours, 4 minutes, and 25 seconds
By "calendar day", we mean the corresponding time on the next day (which may not be 24 hours, due to daylight savings). Similarly for "calendar week", "calendar month", "calendar quarter", and "calendar year".
2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 |
# File 'lib/polars/expr.rb', line 2859 def rolling( index_column:, period:, offset: nil, closed: "right" ) if offset.nil? offset = Utils.negate_duration_string(Utils.parse_as_duration_string(period)) end period = Utils.parse_as_duration_string(period) offset = Utils.parse_as_duration_string(offset) wrap_expr(_rbexpr.rolling(index_column, period, offset, closed)) end |
#rolling_kurtosis(window_size, fisher: true, bias: true, min_samples: nil, center: false) ⇒ Expr
This functionality is considered unstable. It may be changed at any point without it being considered a breaking change.
Compute a rolling kurtosis.
The window at a given row will include the row itself, and the window_size - 1
elements before it.
6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 |
# File 'lib/polars/expr.rb', line 6412 def rolling_kurtosis( window_size, fisher: true, bias: true, min_samples: nil, center: false ) wrap_expr( _rbexpr.rolling_kurtosis( window_size, fisher, bias, min_samples, center ) ) end |
#rolling_max(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
This functionality is experimental and may change without it being considered a breaking change.
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using group_by_rolling
this method can cache the window size
computation.
Apply a rolling max (moving max) over the values in this array.
A window of length window_size
will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
weight
vector. The resulting values will be aggregated to their sum.
5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 |
# File 'lib/polars/expr.rb', line 5791 def rolling_max( window_size, weights: nil, min_periods: nil, center: false ) wrap_expr( _rbexpr.rolling_max( window_size, weights, min_periods, center ) ) end |
#rolling_max_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using rolling
- this method can cache the window size
computation.
Apply a rolling max based on another column.
4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 |
# File 'lib/polars/expr.rb', line 4870 def rolling_max_by( by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil ) window_size = _prepare_rolling_by_window_args(window_size) by = Utils.parse_into_expression(by) wrap_expr( _rbexpr.rolling_max_by(by, window_size, min_periods, closed) ) end |
#rolling_mean(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
This functionality is experimental and may change without it being considered a breaking change.
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using group_by_rolling
this method can cache the window size
computation.
Apply a rolling mean (moving mean) over the values in this array.
A window of length window_size
will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
weight
vector. The resulting values will be aggregated to their sum.
5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 |
# File 'lib/polars/expr.rb', line 5869 def rolling_mean( window_size, weights: nil, min_periods: nil, center: false ) wrap_expr( _rbexpr.rolling_mean( window_size, weights, min_periods, center ) ) end |
#rolling_mean_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using rolling
- this method can cache the window size
computation.
Apply a rolling mean based on another column.
5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 |
# File 'lib/polars/expr.rb', line 5001 def rolling_mean_by( by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil ) window_size = _prepare_rolling_by_window_args(window_size) by = Utils.parse_into_expression(by) wrap_expr( _rbexpr.rolling_mean_by( by, window_size, min_periods, closed ) ) end |
#rolling_median(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
This functionality is experimental and may change without it being considered a breaking change.
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using group_by_rolling
this method can cache the window size
computation.
Compute a rolling median.
6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 |
# File 'lib/polars/expr.rb', line 6183 def rolling_median( window_size, weights: nil, min_periods: nil, center: false ) wrap_expr( _rbexpr.rolling_median( window_size, weights, min_periods, center ) ) end |
#rolling_median_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using rolling
- this method can cache the window size
computation.
Compute a rolling median based on another column.
5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 |
# File 'lib/polars/expr.rb', line 5516 def rolling_median_by( by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil ) window_size = _prepare_rolling_by_window_args(window_size) by = Utils.parse_into_expression(by) wrap_expr( _rbexpr.rolling_median_by(by, window_size, min_periods, closed) ) end |
#rolling_min(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
This functionality is experimental and may change without it being considered a breaking change.
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using group_by_rolling
this method can cache the window size
computation.
Apply a rolling min (moving min) over the values in this array.
A window of length window_size
will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
weight
vector. The resulting values will be aggregated to their sum.
5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 |
# File 'lib/polars/expr.rb', line 5713 def rolling_min( window_size, weights: nil, min_periods: nil, center: false ) wrap_expr( _rbexpr.rolling_min( window_size, weights, min_periods, center ) ) end |
#rolling_min_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using rolling
- this method can cache the window size
computation.
Apply a rolling min based on another column.
4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 |
# File 'lib/polars/expr.rb', line 4741 def rolling_min_by( by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil ) window_size = _prepare_rolling_by_window_args(window_size) by = Utils.parse_into_expression(by) wrap_expr( _rbexpr.rolling_min_by(by, window_size, min_periods, closed) ) end |
#rolling_quantile(quantile, interpolation: "nearest", window_size: 2, weights: nil, min_periods: nil, center: false) ⇒ Expr
This functionality is experimental and may change without it being considered a breaking change.
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using group_by_rolling
this method can cache the window size
computation.
Compute a rolling quantile.
6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 |
# File 'lib/polars/expr.rb', line 6261 def rolling_quantile( quantile, interpolation: "nearest", window_size: 2, weights: nil, min_periods: nil, center: false ) wrap_expr( _rbexpr.rolling_quantile( quantile, interpolation, window_size, weights, min_periods, center ) ) end |
#rolling_quantile_by(by, window_size, quantile:, interpolation: "nearest", min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using rolling
- this method can cache the window size
computation.
Compute a rolling quantile based on another column.
5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 |
# File 'lib/polars/expr.rb', line 5625 def rolling_quantile_by( by, window_size, quantile:, interpolation: "nearest", min_periods: 1, closed: "right", warn_if_unsorted: nil ) window_size = _prepare_rolling_by_window_args(window_size) by = Utils.parse_into_expression(by) wrap_expr( _rbexpr.rolling_quantile_by( by, quantile, interpolation, window_size, min_periods, closed, ) ) end |
#rolling_skew(window_size, bias: true, min_samples: nil, center: false) ⇒ Expr
Compute a rolling skew.
6369 6370 6371 |
# File 'lib/polars/expr.rb', line 6369 def rolling_skew(window_size, bias: true, min_samples: nil, center: false) wrap_expr(_rbexpr.rolling_skew(window_size, bias, min_samples, center)) end |
#rolling_std(window_size, weights: nil, min_periods: nil, center: false, ddof: 1) ⇒ Expr
This functionality is experimental and may change without it being considered a breaking change.
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using group_by_rolling
this method can cache the window size
computation.
Compute a rolling standard deviation.
A window of length window_size
will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
weight
vector. The resulting values will be aggregated to their sum.
6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 |
# File 'lib/polars/expr.rb', line 6027 def rolling_std( window_size, weights: nil, min_periods: nil, center: false, ddof: 1 ) wrap_expr( _rbexpr.rolling_std( window_size, weights, min_periods, center, ddof ) ) end |
#rolling_std_by(by, window_size, min_periods: 1, closed: "right", ddof: 1, warn_if_unsorted: nil) ⇒ Expr
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using rolling
- this method can cache the window size
computation.
Compute a rolling standard deviation based on another column.
5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 |
# File 'lib/polars/expr.rb', line 5266 def rolling_std_by( by, window_size, min_periods: 1, closed: "right", ddof: 1, warn_if_unsorted: nil ) window_size = _prepare_rolling_by_window_args(window_size) by = Utils.parse_into_expression(by) wrap_expr( _rbexpr.rolling_std_by( by, window_size, min_periods, closed, ddof ) ) end |
#rolling_sum(window_size, weights: nil, min_periods: nil, center: false) ⇒ Expr
This functionality is experimental and may change without it being considered a breaking change.
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using group_by_rolling
this method can cache the window size
computation.
Apply a rolling sum (moving sum) over the values in this array.
A window of length window_size
will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
weight
vector. The resulting values will be aggregated to their sum.
5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 |
# File 'lib/polars/expr.rb', line 5947 def rolling_sum( window_size, weights: nil, min_periods: nil, center: false ) wrap_expr( _rbexpr.rolling_sum( window_size, weights, min_periods, center ) ) end |
#rolling_sum_by(by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil) ⇒ Expr
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using rolling
- this method can cache the window size
computation.
Apply a rolling sum based on another column.
5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 |
# File 'lib/polars/expr.rb', line 5135 def rolling_sum_by( by, window_size, min_periods: 1, closed: "right", warn_if_unsorted: nil ) window_size = _prepare_rolling_by_window_args(window_size) by = Utils.parse_into_expression(by) wrap_expr( _rbexpr.rolling_sum_by(by, window_size, min_periods, closed) ) end |
#rolling_var(window_size, weights: nil, min_periods: nil, center: false, ddof: 1) ⇒ Expr
This functionality is experimental and may change without it being considered a breaking change.
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using group_by_rolling
this method can cache the window size
computation.
Compute a rolling variance.
A window of length window_size
will traverse the array. The values that fill
this window will (optionally) be multiplied with the weights given by the
weight
vector. The resulting values will be aggregated to their sum.
6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 |
# File 'lib/polars/expr.rb', line 6108 def rolling_var( window_size, weights: nil, min_periods: nil, center: false, ddof: 1 ) wrap_expr( _rbexpr.rolling_var( window_size, weights, min_periods, center, ddof ) ) end |
#rolling_var_by(by, window_size, min_periods: 1, closed: "right", ddof: 1, warn_if_unsorted: nil) ⇒ Expr
If you want to compute multiple aggregation statistics over the same dynamic
window, consider using rolling
- this method can cache the window size
computation.
Compute a rolling variance based on another column.
5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 |
# File 'lib/polars/expr.rb', line 5404 def rolling_var_by( by, window_size, min_periods: 1, closed: "right", ddof: 1, warn_if_unsorted: nil ) window_size = _prepare_rolling_by_window_args(window_size) by = Utils.parse_into_expression(by) wrap_expr( _rbexpr.rolling_var_by( by, window_size, min_periods, closed, ddof ) ) end |
#round(decimals = 0, mode: "half_to_even") ⇒ Expr
Round underlying floating point data by decimals
digits.
1253 1254 1255 |
# File 'lib/polars/expr.rb', line 1253 def round(decimals = 0, mode: "half_to_even") wrap_expr(_rbexpr.round(decimals, mode)) end |
#round_sig_figs(digits) ⇒ Expr
Round to a number of significant figures.
1278 1279 1280 |
# File 'lib/polars/expr.rb', line 1278 def round_sig_figs(digits) wrap_expr(_rbexpr.round_sig_figs(digits)) end |
#sample(frac: nil, with_replacement: true, shuffle: false, seed: nil, n: nil) ⇒ Expr
Sample from this expression.
7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 |
# File 'lib/polars/expr.rb', line 7274 def sample( frac: nil, with_replacement: true, shuffle: false, seed: nil, n: nil ) if !n.nil? && !frac.nil? raise ArgumentError, "cannot specify both `n` and `frac`" end if !n.nil? && frac.nil? n = Utils.parse_into_expression(n) return wrap_expr(_rbexpr.sample_n(n, with_replacement, shuffle, seed)) end if frac.nil? frac = 1.0 end frac = Utils.parse_into_expression(frac) wrap_expr( _rbexpr.sample_frac(frac, with_replacement, shuffle, seed) ) end |
#search_sorted(element, side: "any", descending: false) ⇒ Expr
Find indices where elements should be inserted to maintain order.
1888 1889 1890 1891 |
# File 'lib/polars/expr.rb', line 1888 def search_sorted(element, side: "any", descending: false) element = Utils.parse_into_expression(element, str_as_lit: false) wrap_expr(_rbexpr.search_sorted(element, side, descending)) end |
#set_sorted(descending: false) ⇒ Expr
This can lead to incorrect results if this Series
is not sorted!!
Use with care!
Flags the expression as 'sorted'.
Enables downstream code to user fast paths for sorted arrays.
7744 7745 7746 |
# File 'lib/polars/expr.rb', line 7744 def set_sorted(descending: false) wrap_expr(_rbexpr.set_sorted_flag(descending)) end |
#shift(n = 1, fill_value: nil) ⇒ Expr
Shift the values by a given period.
2058 2059 2060 2061 2062 2063 2064 |
# File 'lib/polars/expr.rb', line 2058 def shift(n = 1, fill_value: nil) if !fill_value.nil? fill_value = Utils.parse_into_expression(fill_value, str_as_lit: true) end n = Utils.parse_into_expression(n) wrap_expr(_rbexpr.shift(n, fill_value)) end |
#shift_and_fill(periods, fill_value) ⇒ Expr
Shift the values by a given period and fill the resulting null values.
2090 2091 2092 |
# File 'lib/polars/expr.rb', line 2090 def shift_and_fill(periods, fill_value) shift(periods, fill_value: fill_value) end |
#shrink_dtype ⇒ Expr
Shrink numeric columns to the minimal required datatype.
Shrink to the dtype needed to fit the extrema of this Series
.
This can be used to reduce memory pressure.
7779 7780 7781 7782 |
# File 'lib/polars/expr.rb', line 7779 def shrink_dtype warn "`Expr.shrink_dtype` is deprecated and is a no-op; use `Series.shrink_dtype` instead." self end |
#shuffle(seed: nil) ⇒ Expr
Shuffle the contents of this expr.
7237 7238 7239 7240 7241 7242 |
# File 'lib/polars/expr.rb', line 7237 def shuffle(seed: nil) if seed.nil? seed = rand(10000) end wrap_expr(_rbexpr.shuffle(seed)) end |
#sign ⇒ Expr
Compute the element-wise indication of the sign.
6849 6850 6851 |
# File 'lib/polars/expr.rb', line 6849 def sign wrap_expr(_rbexpr.sign) end |
#sin ⇒ Expr
Compute the element-wise value for the sine.
6869 6870 6871 |
# File 'lib/polars/expr.rb', line 6869 def sin wrap_expr(_rbexpr.sin) end |
#sinh ⇒ Expr
Compute the element-wise value for the hyperbolic sine.
7009 7010 7011 |
# File 'lib/polars/expr.rb', line 7009 def sinh wrap_expr(_rbexpr.sinh) end |
#skew(bias: true) ⇒ Expr
Compute the sample skewness of a data set.
For normally distributed data, the skewness should be about zero. For
unimodal continuous distributions, a skewness value greater than zero means
that there is more weight in the right tail of the distribution. The
function skewtest
can be used to determine if the skewness value
is close enough to zero, statistically speaking.
6648 6649 6650 |
# File 'lib/polars/expr.rb', line 6648 def skew(bias: true) wrap_expr(_rbexpr.skew(bias)) end |
#slice(offset, length = nil) ⇒ Expr
Get a slice of this expression.
881 882 883 884 885 886 887 888 889 |
# File 'lib/polars/expr.rb', line 881 def slice(offset, length = nil) if !offset.is_a?(Expr) offset = Polars.lit(offset) end if !length.is_a?(Expr) length = Polars.lit(length) end wrap_expr(_rbexpr.slice(offset._rbexpr, length._rbexpr)) end |
#sort(reverse: false, nulls_last: false) ⇒ Expr
Sort this column. In projection/ selection context the whole column is sorted.
If used in a group by context, the groups are sorted.
1449 1450 1451 |
# File 'lib/polars/expr.rb', line 1449 def sort(reverse: false, nulls_last: false) wrap_expr(_rbexpr.sort_with(reverse, nulls_last)) end |
#sort_by(by, *more_by, reverse: false, nulls_last: false, multithreaded: true, maintain_order: false) ⇒ Expr
Sort this column by the ordering of another column, or multiple other columns.
In projection/ selection context the whole column is sorted. If used in a group by context, the groups are sorted.
1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 |
# File 'lib/polars/expr.rb', line 1944 def sort_by(by, *more_by, reverse: false, nulls_last: false, multithreaded: true, maintain_order: false) by = Utils.parse_into_list_of_expressions(by, *more_by) reverse = Utils.extend_bool(reverse, by.length, "reverse", "by") nulls_last = Utils.extend_bool(nulls_last, by.length, "nulls_last", "by") wrap_expr( _rbexpr.sort_by( by, reverse, nulls_last, multithreaded, maintain_order ) ) end |
#sqrt ⇒ Expr
Compute the square root of the elements.
309 310 311 |
# File 'lib/polars/expr.rb', line 309 def sqrt wrap_expr(_rbexpr.sqrt) end |
#std(ddof: 1) ⇒ Expr
Get standard deviation.
2315 2316 2317 |
# File 'lib/polars/expr.rb', line 2315 def std(ddof: 1) wrap_expr(_rbexpr.std(ddof)) end |
#str ⇒ StringExpr
Create an object namespace of all string related methods.
8364 8365 8366 |
# File 'lib/polars/expr.rb', line 8364 def str StringExpr.new(self) end |
#struct ⇒ StructExpr
Create an object namespace of all struct related methods.
8371 8372 8373 |
# File 'lib/polars/expr.rb', line 8371 def struct StructExpr.new(self) end |
#sub(other) ⇒ Expr
Method equivalent of subtraction operator expr - other
.
4191 4192 4193 |
# File 'lib/polars/expr.rb', line 4191 def sub(other) self - other end |
#suffix(suffix) ⇒ Expr
Add a suffix to the root column name of the expression.
528 529 530 |
# File 'lib/polars/expr.rb', line 528 def suffix(suffix) name.suffix(suffix) end |
#sum ⇒ Expr
Dtypes in :i8
, :u8
, :i16
, and :u16
are cast to
:i64
before summing to prevent overflow issues.
Get sum value.
2442 2443 2444 |
# File 'lib/polars/expr.rb', line 2442 def sum wrap_expr(_rbexpr.sum) end |
#tail(n = 10) ⇒ Expr
Get the last n
rows.
3642 3643 3644 |
# File 'lib/polars/expr.rb', line 3642 def tail(n = 10) wrap_expr(_rbexpr.tail(n)) end |
#tan ⇒ Expr
Compute the element-wise value for the tangent.
6909 6910 6911 |
# File 'lib/polars/expr.rb', line 6909 def tan wrap_expr(_rbexpr.tan) end |
#tanh ⇒ Expr
Compute the element-wise value for the hyperbolic tangent.
7049 7050 7051 |
# File 'lib/polars/expr.rb', line 7049 def tanh wrap_expr(_rbexpr.tanh) end |
#to_physical ⇒ Expr
Cast to physical representation of the logical dtype.
:date
->:i32
:datetime
->:i64
:time
->:i64
:duration
->:i64
:cat
->:u32
- Other data types will be left unchanged.
216 217 218 |
# File 'lib/polars/expr.rb', line 216 def to_physical wrap_expr(_rbexpr.to_physical) end |
#to_s ⇒ String Also known as: inspect
Returns a string representing the Expr.
20 21 22 |
# File 'lib/polars/expr.rb', line 20 def to_s _rbexpr.to_str end |
#top_k(k: 5) ⇒ Expr
Return the k
largest elements.
If 'reverse: true` the smallest elements will be given.
1487 1488 1489 1490 |
# File 'lib/polars/expr.rb', line 1487 def top_k(k: 5) k = Utils.parse_into_expression(k) wrap_expr(_rbexpr.top_k(k)) end |
#top_k_by(by, k: 5, reverse: false) ⇒ Expr
Return the elements corresponding to the k
largest elements of the by
column(s).
Non-null elements are always preferred over null elements, regardless of
the value of reverse
. The output is not guaranteed to be in any
particular order, call :func:sort
after this function if you wish the
output to be sorted.
1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 |
# File 'lib/polars/expr.rb', line 1587 def top_k_by( by, k: 5, reverse: false ) k = Utils.parse_into_expression(k) by = Utils.parse_into_list_of_expressions(by) reverse = Utils.extend_bool(reverse, by.length, "reverse", "by") wrap_expr(_rbexpr.top_k_by(by, k, reverse)) end |
#truediv(other) ⇒ Expr
Method equivalent of float division operator expr / other
.
4246 4247 4248 |
# File 'lib/polars/expr.rb', line 4246 def truediv(other) self / other end |
#unique(maintain_order: false) ⇒ Expr
Get unique values of this expression.
2660 2661 2662 2663 2664 2665 2666 |
# File 'lib/polars/expr.rb', line 2660 def unique(maintain_order: false) if maintain_order wrap_expr(_rbexpr.unique_stable) else wrap_expr(_rbexpr.unique) end end |
#unique_counts ⇒ Expr
Return a count of the unique values in the order of appearance.
This method differs from value_counts
in that it does not return the
values, only the counts and might be faster
7580 7581 7582 |
# File 'lib/polars/expr.rb', line 7580 def unique_counts wrap_expr(_rbexpr.unique_counts) end |
#upper_bound ⇒ Expr
Calculate the upper bound.
Returns a unit Series with the highest value possible for the dtype of this expression.
6825 6826 6827 |
# File 'lib/polars/expr.rb', line 6825 def upper_bound wrap_expr(_rbexpr.upper_bound) end |
#value_counts(sort: false, parallel: false, name: nil, normalize: false) ⇒ Expr
Count all unique values and create a struct mapping value to count.
7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 |
# File 'lib/polars/expr.rb', line 7533 def value_counts( sort: false, parallel: false, name: nil, normalize: false ) if name.nil? if normalize name = "proportion" else name = "count" end end wrap_expr( _rbexpr.value_counts(sort, parallel, name, normalize) ) end |
#var(ddof: 1) ⇒ Expr
Get variance.
2338 2339 2340 |
# File 'lib/polars/expr.rb', line 2338 def var(ddof: 1) wrap_expr(_rbexpr.var(ddof)) end |
#where(predicate) ⇒ Expr
Filter a single column.
Alias for #filter.
3367 3368 3369 |
# File 'lib/polars/expr.rb', line 3367 def where(predicate) filter(predicate) end |
#xor(other) ⇒ Expr
Method equivalent of bitwise exclusive-or operator expr ^ other
.
4300 4301 4302 |
# File 'lib/polars/expr.rb', line 4300 def xor(other) self ^ other end |
#|(other) ⇒ Expr
Bitwise OR.
44 45 46 47 |
# File 'lib/polars/expr.rb', line 44 def |(other) other = Utils.parse_into_expression(other) wrap_expr(_rbexpr.or_(other)) end |