Enum Expr
pub enum Expr {
Show 27 variants
Element,
Alias(Arc<Expr>, PlSmallStr),
Column(PlSmallStr),
Selector(Selector),
Literal(LiteralValue),
DataTypeFunction(DataTypeFunction),
BinaryExpr {
left: Arc<Expr>,
op: Operator,
right: Arc<Expr>,
},
Cast {
expr: Arc<Expr>,
dtype: DataTypeExpr,
options: CastOptions,
},
Sort {
expr: Arc<Expr>,
options: SortOptions,
},
Gather {
expr: Arc<Expr>,
idx: Arc<Expr>,
returns_scalar: bool,
null_on_oob: bool,
},
SortBy {
expr: Arc<Expr>,
by: Vec<Expr>,
sort_options: SortMultipleOptions,
},
Agg(AggExpr),
Ternary {
predicate: Arc<Expr>,
truthy: Arc<Expr>,
falsy: Arc<Expr>,
},
Function {
input: Vec<Expr>,
function: FunctionExpr,
},
Explode {
input: Arc<Expr>,
options: ExplodeOptions,
},
Filter {
input: Arc<Expr>,
by: Arc<Expr>,
},
Over {
function: Arc<Expr>,
partition_by: Vec<Expr>,
order_by: Option<(Arc<Expr>, SortOptions)>,
mapping: WindowMapping,
},
Rolling {
function: Arc<Expr>,
index_column: Arc<Expr>,
period: Duration,
offset: Duration,
closed_window: ClosedWindow,
},
Slice {
input: Arc<Expr>,
offset: Arc<Expr>,
length: Arc<Expr>,
},
KeepName(Arc<Expr>),
Len,
Field(Arc<[PlSmallStr]>),
AnonymousFunction {
input: Vec<Expr>,
function: LazySerde<SpecialEq<Arc<dyn AnonymousColumnsUdf>>>,
options: FunctionOptions,
fmt_str: Box<PlSmallStr>,
},
Eval {
expr: Arc<Expr>,
evaluation: Arc<Expr>,
variant: EvalVariant,
},
StructEval {
expr: Arc<Expr>,
evaluation: Vec<Expr>,
},
SubPlan(SpecialEq<Arc<DslPlan>>, Vec<String>),
RenameAlias {
function: RenameAliasFn,
expr: Arc<Expr>,
},
}Expand description
Expressions that can be used in various contexts.
Queries consist of multiple expressions.
When using the polars lazy API, don’t construct an Expr directly; instead, create one using
the functions in the polars_lazy::dsl module. See that module’s docs for more info.
Variants§
Element
Values in a eval context.
Equivalent of pl.element().
Alias(Arc<Expr>, PlSmallStr)
Column(PlSmallStr)
Selector(Selector)
Literal(LiteralValue)
DataTypeFunction(DataTypeFunction)
BinaryExpr
Cast
Sort
Gather
SortBy
Agg(AggExpr)
Ternary
A ternary operation if true then “foo” else “bar”
Function
Explode
Filter
Over
Polars flavored window functions.
Rolling
dynamic_group_by only.Fields
closed_window: ClosedWindowSlice
Fields
KeepName(Arc<Expr>)
Set root name as Alias
Len
Field(Arc<[PlSmallStr]>)
dtype-struct only.AnonymousFunction
Fields
function: LazySerde<SpecialEq<Arc<dyn AnonymousColumnsUdf>>>function to apply
options: FunctionOptionsfmt_str: Box<PlSmallStr>used for formatting
Eval
Evaluates the evaluation expression on the output of the expr.
Consequently, expr is an input and evaluation is not and needs a different schema.
StructEval
dtype-struct only.Evaluates the evaluation expressions on the output of the expr.
Consequently, expr is an input and evaluation uses an extended schema that includes this input.
SubPlan(SpecialEq<Arc<DslPlan>>, Vec<String>)
RenameAlias
Implementations§
§impl Expr
impl Expr
pub fn cos(self) -> Expr
Available on crate feature trigonometry only.
pub fn cos(self) -> Expr
trigonometry only.Compute the cosine of the given expression
pub fn cot(self) -> Expr
Available on crate feature trigonometry only.
pub fn cot(self) -> Expr
trigonometry only.Compute the cotangent of the given expression
pub fn sin(self) -> Expr
Available on crate feature trigonometry only.
pub fn sin(self) -> Expr
trigonometry only.Compute the sine of the given expression
pub fn tan(self) -> Expr
Available on crate feature trigonometry only.
pub fn tan(self) -> Expr
trigonometry only.Compute the tangent of the given expression
pub fn arccos(self) -> Expr
Available on crate feature trigonometry only.
pub fn arccos(self) -> Expr
trigonometry only.Compute the inverse cosine of the given expression
pub fn arcsin(self) -> Expr
Available on crate feature trigonometry only.
pub fn arcsin(self) -> Expr
trigonometry only.Compute the inverse sine of the given expression
pub fn arctan(self) -> Expr
Available on crate feature trigonometry only.
pub fn arctan(self) -> Expr
trigonometry only.Compute the inverse tangent of the given expression
pub fn arctan2(self, x: Expr) -> Expr
Available on crate feature trigonometry only.
pub fn arctan2(self, x: Expr) -> Expr
trigonometry only.Compute the inverse tangent of the given expression, with the angle expressed as the argument of a complex number
pub fn cosh(self) -> Expr
Available on crate feature trigonometry only.
pub fn cosh(self) -> Expr
trigonometry only.Compute the hyperbolic cosine of the given expression
pub fn sinh(self) -> Expr
Available on crate feature trigonometry only.
pub fn sinh(self) -> Expr
trigonometry only.Compute the hyperbolic sine of the given expression
pub fn tanh(self) -> Expr
Available on crate feature trigonometry only.
pub fn tanh(self) -> Expr
trigonometry only.Compute the hyperbolic tangent of the given expression
pub fn arccosh(self) -> Expr
Available on crate feature trigonometry only.
pub fn arccosh(self) -> Expr
trigonometry only.Compute the inverse hyperbolic cosine of the given expression
pub fn arcsinh(self) -> Expr
Available on crate feature trigonometry only.
pub fn arcsinh(self) -> Expr
trigonometry only.Compute the inverse hyperbolic sine of the given expression
pub fn arctanh(self) -> Expr
Available on crate feature trigonometry only.
pub fn arctanh(self) -> Expr
trigonometry only.Compute the inverse hyperbolic tangent of the given expression
pub fn degrees(self) -> Expr
Available on crate feature trigonometry only.
pub fn degrees(self) -> Expr
trigonometry only.Convert from radians to degrees
§impl Expr
impl Expr
pub fn bitwise_count_ones(self) -> Expr
pub fn bitwise_count_ones(self) -> Expr
Evaluate the number of set bits.
pub fn bitwise_count_zeros(self) -> Expr
pub fn bitwise_count_zeros(self) -> Expr
Evaluate the number of unset bits.
pub fn bitwise_leading_ones(self) -> Expr
pub fn bitwise_leading_ones(self) -> Expr
Evaluate the number most-significant set bits before seeing an unset bit.
pub fn bitwise_leading_zeros(self) -> Expr
pub fn bitwise_leading_zeros(self) -> Expr
Evaluate the number most-significant unset bits before seeing an set bit.
pub fn bitwise_trailing_ones(self) -> Expr
pub fn bitwise_trailing_ones(self) -> Expr
Evaluate the number least-significant set bits before seeing an unset bit.
pub fn bitwise_trailing_zeros(self) -> Expr
pub fn bitwise_trailing_zeros(self) -> Expr
Evaluate the number least-significant unset bits before seeing an set bit.
pub fn bitwise_and(self) -> Expr
pub fn bitwise_and(self) -> Expr
Perform an aggregation of bitwise ANDs
pub fn bitwise_or(self) -> Expr
pub fn bitwise_or(self) -> Expr
Perform an aggregation of bitwise ORs
pub fn bitwise_xor(self) -> Expr
pub fn bitwise_xor(self) -> Expr
Perform an aggregation of bitwise XORs
§impl Expr
impl Expr
pub fn to_field(&self, schema: &Schema<DataType>) -> Result<Field, PolarsError>
pub fn to_field(&self, schema: &Schema<DataType>) -> Result<Field, PolarsError>
Get Field result of the expression. The schema is the input data.
pub fn into_selector(self) -> Option<Selector>
pub fn try_into_selector(self) -> Result<Selector, PolarsError>
pub fn extract_usize(&self) -> Result<usize, PolarsError>
pub fn extract_usize(&self) -> Result<usize, PolarsError>
Extract a constant usize from an expression.
pub fn extract_i64(&self) -> Result<i64, PolarsError>
pub fn map_unary(self, function: impl Into<FunctionExpr>) -> Expr
pub fn map_binary(self, function: impl Into<FunctionExpr>, rhs: Expr) -> Expr
pub fn map_ternary( self, function: impl Into<FunctionExpr>, arg1: Expr, arg2: Expr, ) -> Expr
pub fn try_map_n_ary( self, function: impl Into<FunctionExpr>, exprs: impl IntoIterator<Item = Result<Expr, PolarsError>>, ) -> Result<Expr, PolarsError>
pub fn map_n_ary( self, function: impl Into<FunctionExpr>, exprs: impl IntoIterator<Item = Expr>, ) -> Expr
pub fn n_ary(function: impl Into<FunctionExpr>, input: Vec<Expr>) -> Expr
§impl Expr
impl Expr
pub fn map_python(self, func: PythonUdfExpression) -> Expr
pub fn map_many_python(exprs: Vec<Expr>, func: PythonUdfExpression) -> Expr
§impl Expr
impl Expr
pub fn eq_missing<E>(self, other: E) -> Expr
pub fn eq_missing<E>(self, other: E) -> Expr
Compare Expr with other Expr on equality where None == None.
pub fn neq_missing<E>(self, other: E) -> Expr
pub fn neq_missing<E>(self, other: E) -> Expr
Compare Expr with other Expr on non-equality where None == None.
pub fn alias<S>(self, name: S) -> Exprwhere
S: Into<PlSmallStr>,
pub fn alias<S>(self, name: S) -> Exprwhere
S: Into<PlSmallStr>,
Rename Column.
pub fn is_not_null(self) -> Expr
pub fn is_not_null(self) -> Expr
Run is_not_null operation on Expr.
pub fn drop_nulls(self) -> Expr
pub fn drop_nulls(self) -> Expr
Drop null values.
pub fn first_non_null(self) -> Expr
pub fn first_non_null(self) -> Expr
Get the first non-nullvalue in the group.
pub fn last_non_null(self) -> Expr
pub fn last_non_null(self) -> Expr
Get the last non-null value in the group.
pub fn item(self, allow_empty: bool) -> Expr
pub fn item(self, allow_empty: bool) -> Expr
Get the single value in the group. If there are multiple values, an error is returned.
pub fn quantile(self, quantile: Expr, method: QuantileMethod) -> Expr
pub fn quantile(self, quantile: Expr, method: QuantileMethod) -> Expr
Compute the quantile per group.
pub fn agg_groups(self) -> Expr
pub fn agg_groups(self) -> Expr
Get the group indexes of the group by operation.
pub fn explode(self, options: ExplodeOptions) -> Expr
pub fn explode(self, options: ExplodeOptions) -> Expr
Explode the String/List column.
pub fn append<E>(self, other: E, upcast: bool) -> Expr
pub fn append<E>(self, other: E, upcast: bool) -> Expr
Append expressions. This is done by adding the chunks of other to this Series.
pub fn unique_stable(self) -> Expr
pub fn unique_stable(self) -> Expr
Get unique values of this expression, while maintaining order.
This requires more work than Expr::unique.
pub fn arg_unique(self) -> Expr
pub fn arg_unique(self) -> Expr
Get the first index of unique values of this expression.
pub fn arg_sort(self, descending: bool, nulls_last: bool) -> Expr
pub fn arg_sort(self, descending: bool, nulls_last: bool) -> Expr
Get the index values that would sort this expression.
pub fn index_of<E>(self, element: E) -> Expr
Available on crate feature index_of only.
pub fn index_of<E>(self, element: E) -> Expr
index_of only.Find the index of a value.
pub fn search_sorted<E>(
self,
element: E,
side: SearchSortedSide,
descending: bool,
) -> Expr
Available on crate feature search_sorted only.
pub fn search_sorted<E>( self, element: E, side: SearchSortedSide, descending: bool, ) -> Expr
search_sorted only.Find indices where elements should be inserted to maintain order.
pub fn strict_cast(self, dtype: impl Into<DataTypeExpr>) -> Expr
pub fn strict_cast(self, dtype: impl Into<DataTypeExpr>) -> Expr
Cast expression to another data type. Throws an error if conversion had overflows. Returns an Error if cast is invalid on rows after predicates are pushed down.
pub fn cast(self, dtype: impl Into<DataTypeExpr>) -> Expr
pub fn cast(self, dtype: impl Into<DataTypeExpr>) -> Expr
Cast expression to another data type.
pub fn cast_with_options(
self,
dtype: impl Into<DataTypeExpr>,
cast_options: CastOptions,
) -> Expr
pub fn cast_with_options( self, dtype: impl Into<DataTypeExpr>, cast_options: CastOptions, ) -> Expr
Cast expression to another data type.
pub fn sort(self, options: SortOptions) -> Expr
pub fn sort(self, options: SortOptions) -> Expr
Sort with given options.
§Example
let lf = df! {
"a" => [Some(5), Some(4), Some(3), Some(2), None]
}?
.lazy();
let sorted = lf
.select(
vec![col("a").sort(SortOptions::default())],
)
.collect()?;
assert_eq!(
sorted,
df! {
"a" => [None, Some(2), Some(3), Some(4), Some(5)]
}?
);See SortOptions for more options.
pub fn top_k(self, k: Expr) -> Expr
Available on crate feature top_k only.
pub fn top_k(self, k: Expr) -> Expr
top_k only.Returns the k largest elements.
This has time complexity O(n + k log(n)).
pub fn top_k_by<K, E, IE>(self, k: K, by: E, descending: Vec<bool>) -> Expr
Available on crate feature top_k only.
pub fn top_k_by<K, E, IE>(self, k: K, by: E, descending: Vec<bool>) -> Expr
top_k only.Returns the k largest rows by given column.
For single column, use Expr::top_k.
pub fn bottom_k(self, k: Expr) -> Expr
Available on crate feature top_k only.
pub fn bottom_k(self, k: Expr) -> Expr
top_k only.Returns the k smallest elements.
This has time complexity O(n + k log(n)).
pub fn bottom_k_by<K, E, IE>(self, k: K, by: E, descending: Vec<bool>) -> Expr
Available on crate feature top_k only.
pub fn bottom_k_by<K, E, IE>(self, k: K, by: E, descending: Vec<bool>) -> Expr
top_k only.Returns the k smallest rows by given column.
For single column, use Expr::bottom_k.
pub fn map<F, DT>(self, function: F, output_type: DT) -> Expr
pub fn map<F, DT>(self, function: F, output_type: DT) -> Expr
Apply a function/closure once the logical plan get executed.
This function is very similar to Expr::apply, but differs in how it handles aggregations.
mapshould be used for operations that are independent of groups, e.g.multiply * 2, orraise to the powerapplyshould be used for operations that work on a group of data. e.g.sum,count, etc.
It is the responsibility of the caller that the schema is correct by giving the correct output_type. If None given the output type of the input expr is used.
pub fn map_with_fmt_str<F, DT>( self, function: F, output_type: DT, fmt_str: impl Into<PlSmallStr>, ) -> Expr
pub fn agg_with_fmt_str<F, DT>( self, function: F, output_type: DT, fmt_str: impl Into<PlSmallStr>, ) -> Expr
pub fn apply_with_fmt_str<F, DT>( self, function: F, output_type: DT, fmt_str: impl Into<PlSmallStr>, ) -> Expr
pub fn apply<F, DT>(self, function: F, output_type: DT) -> Expr
pub fn apply<F, DT>(self, function: F, output_type: DT) -> Expr
Apply a function/closure over the groups. This should only be used in a group_by aggregation.
It is the responsibility of the caller that the schema is correct by giving the correct output_type. If None given the output type of the input expr is used.
This difference with map is that apply will create a separate Series per group.
mapshould be used for operations that are independent of groups, e.g.multiply * 2, orraise to the powerapplyshould be used for operations that work on a group of data. e.g.sum,count, etc.
pub fn apply_many<F, DT>(
self,
function: F,
arguments: &[Expr],
output_type: DT,
) -> Expr
pub fn apply_many<F, DT>( self, function: F, arguments: &[Expr], output_type: DT, ) -> Expr
Apply a function/closure over the groups with many arguments. This should only be used in a group_by aggregation.
See the Expr::apply function for the differences between map and apply.
pub fn is_infinite(self) -> Expr
pub fn is_infinite(self) -> Expr
Get mask of infinite values if dtype is Float.
pub fn is_not_nan(self) -> Expr
pub fn is_not_nan(self) -> Expr
Get inverse mask of NaN values if dtype is Float.
pub fn shift(self, n: Expr) -> Expr
pub fn shift(self, n: Expr) -> Expr
Shift the values in the array by some period. See the eager implementation.
pub fn shift_and_fill<E, IE>(self, n: E, fill_value: IE) -> Expr
pub fn shift_and_fill<E, IE>(self, n: E, fill_value: IE) -> Expr
Shift the values in the array by some period and fill the resulting empty values.
pub fn cumulative_eval(self, evaluation: Expr, min_samples: usize) -> Expr
Available on crate feature cum_agg only.
pub fn cumulative_eval(self, evaluation: Expr, min_samples: usize) -> Expr
cum_agg only.Cumulatively count values from 0 to len.
pub fn cum_count(self, reverse: bool) -> Expr
Available on crate feature cum_agg only.
pub fn cum_count(self, reverse: bool) -> Expr
cum_agg only.Cumulatively count values from 0 to len.
pub fn cum_sum(self, reverse: bool) -> Expr
Available on crate feature cum_agg only.
pub fn cum_sum(self, reverse: bool) -> Expr
cum_agg only.Get an array with the cumulative sum computed at every element.
pub fn cum_prod(self, reverse: bool) -> Expr
Available on crate feature cum_agg only.
pub fn cum_prod(self, reverse: bool) -> Expr
cum_agg only.Get an array with the cumulative product computed at every element.
pub fn cum_min(self, reverse: bool) -> Expr
Available on crate feature cum_agg only.
pub fn cum_min(self, reverse: bool) -> Expr
cum_agg only.Get an array with the cumulative min computed at every element.
pub fn cum_max(self, reverse: bool) -> Expr
Available on crate feature cum_agg only.
pub fn cum_max(self, reverse: bool) -> Expr
cum_agg only.Get an array with the cumulative max computed at every element.
pub fn round(self, decimals: u32, mode: RoundMode) -> Expr
Available on crate feature round_series only.
pub fn round(self, decimals: u32, mode: RoundMode) -> Expr
round_series only.Round underlying floating point array to given decimal numbers.
pub fn round_sig_figs(self, digits: i32) -> Expr
Available on crate feature round_series only.
pub fn round_sig_figs(self, digits: i32) -> Expr
round_series only.Round to a number of significant figures.
pub fn floor(self) -> Expr
Available on crate feature round_series only.
pub fn floor(self) -> Expr
round_series only.Floor underlying floating point array to the lowest integers smaller or equal to the float value.
pub fn ceil(self) -> Expr
Available on crate feature round_series only.
pub fn ceil(self) -> Expr
round_series only.Ceil underlying floating point array to the highest integers smaller or equal to the float value.
pub fn clip(self, min: Expr, max: Expr) -> Expr
Available on crate feature round_series only.
pub fn clip(self, min: Expr, max: Expr) -> Expr
round_series only.Clip underlying values to a set boundary.
pub fn clip_max(self, max: Expr) -> Expr
Available on crate feature round_series only.
pub fn clip_max(self, max: Expr) -> Expr
round_series only.Clip underlying values to a set boundary.
pub fn clip_min(self, min: Expr) -> Expr
Available on crate feature round_series only.
pub fn clip_min(self, min: Expr) -> Expr
round_series only.Clip underlying values to a set boundary.
pub fn abs(self) -> Expr
Available on crate feature abs only.
pub fn abs(self) -> Expr
abs only.Convert all values to their absolute/positive value.
pub fn over<E, IE>(self, partition_by: E) -> Expr
pub fn over<E, IE>(self, partition_by: E) -> Expr
Apply window function over a subgroup. This is similar to a group_by + aggregation + self join. Or similar to window functions in Postgres.
§Example
#[macro_use] extern crate polars_core;
use polars_core::prelude::*;
use polars_lazy::prelude::*;
fn example() -> PolarsResult<()> {
let df = df! {
"groups" => &[1, 1, 2, 2, 1, 2, 3, 3, 1],
"values" => &[1, 2, 3, 4, 5, 6, 7, 8, 8]
}?;
let out = df
.lazy()
.select(&[
col("groups"),
sum("values").over([col("groups")]),
])
.collect()?;
println!("{}", &out);
Ok(())
}
Outputs:
╭────────┬────────╮
│ groups ┆ values │
│ --- ┆ --- │
│ i32 ┆ i32 │
╞════════╪════════╡
│ 1 ┆ 16 │
│ 1 ┆ 16 │
│ 2 ┆ 13 │
│ 2 ┆ 13 │
│ … ┆ … │
│ 1 ┆ 16 │
│ 2 ┆ 13 │
│ 3 ┆ 15 │
│ 3 ┆ 15 │
│ 1 ┆ 16 │
╰────────┴────────╯pub fn over_with_options<E, IE>( self, partition_by: Option<E>, order_by: Option<(E, SortOptions)>, mapping: WindowMapping, ) -> Result<Expr, PolarsError>
pub fn rolling( self, index_column: impl Into<Expr>, period: Duration, offset: Duration, closed_window: ClosedWindow, ) -> Expr
dynamic_group_by only.pub fn fill_null_with_strategy(self, strategy: FillNullStrategy) -> Expr
pub fn len(self) -> Expr
pub fn is_duplicated(self) -> Expr
Available on crate feature is_unique only.
pub fn is_duplicated(self) -> Expr
is_unique only.Get a mask of duplicated values.
pub fn is_between<E>(self, lower: E, upper: E, closed: ClosedInterval) -> Expr
is_between only.pub fn is_unique(self) -> Expr
Available on crate feature is_unique only.
pub fn is_unique(self) -> Expr
is_unique only.Get a mask of unique values.
pub fn is_close<E>(
self,
expr: E,
abs_tol: f64,
rel_tol: f64,
nans_equal: bool,
) -> Expr
Available on crate feature is_close only.
pub fn is_close<E>( self, expr: E, abs_tol: f64, rel_tol: f64, nans_equal: bool, ) -> Expr
is_close only.Check whether floating point values are close to each other.
pub fn approx_n_unique(self) -> Expr
Available on crate feature approx_unique only.
pub fn approx_n_unique(self) -> Expr
approx_unique only.Get the approximate count of unique values.
pub fn logical_or<E>(self, expr: E) -> Expr
pub fn logical_or<E>(self, expr: E) -> Expr
Logical “or” operation.
pub fn logical_and<E>(self, expr: E) -> Expr
pub fn logical_and<E>(self, expr: E) -> Expr
Logical “and” operation.
pub fn filter<E>(self, predicate: E) -> Expr
pub fn filter<E>(self, predicate: E) -> Expr
Filter a single column.
Should be used in aggregation context. If you want to filter on a
DataFrame level, use LazyFrame::filter.
pub fn is_in<E>(self, other: E, nulls_equal: bool) -> Expr
Available on crate feature is_in only.
pub fn is_in<E>(self, other: E, nulls_equal: bool) -> Expr
is_in only.Check if the values of the left expression are in the lists of the right expr.
pub fn sort_by<E, IE>(self, by: E, sort_options: SortMultipleOptions) -> Expr
pub fn sort_by<E, IE>(self, by: E, sort_options: SortMultipleOptions) -> Expr
Sort this column by the ordering of another column evaluated from given expr. Can also be used in a group_by context to sort the groups.
§Example
let lf = df! {
"a" => [1, 2, 3, 4, 5],
"b" => [5, 4, 3, 2, 1]
}?.lazy();
let sorted = lf
.select(
vec![col("a").sort_by(col("b"), SortOptions::default())],
)
.collect()?;
assert_eq!(
sorted,
df! { "a" => [5, 4, 3, 2, 1] }?
);pub fn repeat_by<E>(self, by: E) -> Expr
Available on crate feature repeat_by only.
pub fn repeat_by<E>(self, by: E) -> Expr
repeat_by only.Repeat the column n times, where n is determined by the values in by.
This yields an Expr of dtype List.
pub fn is_first_distinct(self) -> Expr
Available on crate feature is_first_distinct only.
pub fn is_first_distinct(self) -> Expr
is_first_distinct only.Get a mask of the first unique value.
pub fn is_last_distinct(self) -> Expr
Available on crate feature is_last_distinct only.
pub fn is_last_distinct(self) -> Expr
is_last_distinct only.Get a mask of the last unique value.
pub fn mode(self, maintain_order: bool) -> Expr
Available on crate feature mode only.
pub fn mode(self, maintain_order: bool) -> Expr
mode only.Compute the mode(s) of this column. This is the most occurring value.
pub fn interpolate(self, method: InterpolationMethod) -> Expr
Available on crate feature interpolate only.
pub fn interpolate(self, method: InterpolationMethod) -> Expr
interpolate only.Interpolate intermediate values. Nulls at the beginning and end of the series remain null.
pub fn interpolate_by(self, by: Expr) -> Expr
Available on crate feature interpolate_by only.
pub fn interpolate_by(self, by: Expr) -> Expr
interpolate_by only.Interpolate intermediate values.
Nulls at the beginning and end of the series remain null.
The by column provides the x-coordinates for interpolation and must not contain nulls.
pub fn rolling_min_by(
self,
by: Expr,
options: RollingOptionsDynamicWindow,
) -> Expr
Available on crate feature rolling_window_by only.
pub fn rolling_min_by( self, by: Expr, options: RollingOptionsDynamicWindow, ) -> Expr
rolling_window_by only.Apply a rolling minimum based on another column.
pub fn rolling_max_by(
self,
by: Expr,
options: RollingOptionsDynamicWindow,
) -> Expr
Available on crate feature rolling_window_by only.
pub fn rolling_max_by( self, by: Expr, options: RollingOptionsDynamicWindow, ) -> Expr
rolling_window_by only.Apply a rolling maximum based on another column.
pub fn rolling_mean_by(
self,
by: Expr,
options: RollingOptionsDynamicWindow,
) -> Expr
Available on crate feature rolling_window_by only.
pub fn rolling_mean_by( self, by: Expr, options: RollingOptionsDynamicWindow, ) -> Expr
rolling_window_by only.Apply a rolling mean based on another column.
pub fn rolling_sum_by(
self,
by: Expr,
options: RollingOptionsDynamicWindow,
) -> Expr
Available on crate feature rolling_window_by only.
pub fn rolling_sum_by( self, by: Expr, options: RollingOptionsDynamicWindow, ) -> Expr
rolling_window_by only.Apply a rolling sum based on another column.
pub fn rolling_quantile_by(
self,
by: Expr,
method: QuantileMethod,
quantile: f64,
options: RollingOptionsDynamicWindow,
) -> Expr
Available on crate feature rolling_window_by only.
pub fn rolling_quantile_by( self, by: Expr, method: QuantileMethod, quantile: f64, options: RollingOptionsDynamicWindow, ) -> Expr
rolling_window_by only.Apply a rolling quantile based on another column.
pub fn rolling_var_by(
self,
by: Expr,
options: RollingOptionsDynamicWindow,
) -> Expr
Available on crate feature rolling_window_by only.
pub fn rolling_var_by( self, by: Expr, options: RollingOptionsDynamicWindow, ) -> Expr
rolling_window_by only.Apply a rolling variance based on another column.
pub fn rolling_std_by(
self,
by: Expr,
options: RollingOptionsDynamicWindow,
) -> Expr
Available on crate feature rolling_window_by only.
pub fn rolling_std_by( self, by: Expr, options: RollingOptionsDynamicWindow, ) -> Expr
rolling_window_by only.Apply a rolling std-dev based on another column.
pub fn rolling_median_by(
self,
by: Expr,
options: RollingOptionsDynamicWindow,
) -> Expr
Available on crate feature rolling_window_by only.
pub fn rolling_median_by( self, by: Expr, options: RollingOptionsDynamicWindow, ) -> Expr
rolling_window_by only.Apply a rolling median based on another column.
pub fn rolling_rank_by( self, by: Expr, options: RollingOptionsDynamicWindow, ) -> Expr
rolling_window_by only.pub fn rolling_min(self, options: RollingOptionsFixedWindow) -> Expr
Available on crate feature rolling_window only.
pub fn rolling_min(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window only.Apply a rolling minimum.
See: [RollingAgg::rolling_min]
pub fn rolling_max(self, options: RollingOptionsFixedWindow) -> Expr
Available on crate feature rolling_window only.
pub fn rolling_max(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window only.Apply a rolling maximum.
See: [RollingAgg::rolling_max]
pub fn rolling_mean(self, options: RollingOptionsFixedWindow) -> Expr
Available on crate feature rolling_window only.
pub fn rolling_mean(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window only.Apply a rolling mean.
See: [RollingAgg::rolling_mean]
pub fn rolling_sum(self, options: RollingOptionsFixedWindow) -> Expr
Available on crate feature rolling_window only.
pub fn rolling_sum(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window only.Apply a rolling sum.
See: [RollingAgg::rolling_sum]
pub fn rolling_median(self, options: RollingOptionsFixedWindow) -> Expr
Available on crate feature rolling_window only.
pub fn rolling_median(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window only.Apply a rolling median.
See: [RollingAgg::rolling_median]
pub fn rolling_quantile(
self,
method: QuantileMethod,
quantile: f64,
options: RollingOptionsFixedWindow,
) -> Expr
Available on crate feature rolling_window only.
pub fn rolling_quantile( self, method: QuantileMethod, quantile: f64, options: RollingOptionsFixedWindow, ) -> Expr
rolling_window only.Apply a rolling quantile.
See: [RollingAgg::rolling_quantile]
pub fn rolling_var(self, options: RollingOptionsFixedWindow) -> Expr
Available on crate feature rolling_window only.
pub fn rolling_var(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window only.Apply a rolling variance.
pub fn rolling_std(self, options: RollingOptionsFixedWindow) -> Expr
Available on crate feature rolling_window only.
pub fn rolling_std(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window only.Apply a rolling std-dev.
pub fn rolling_rank(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window only.pub fn rolling_skew(self, options: RollingOptionsFixedWindow) -> Expr
Available on crate features rolling_window and moment only.
pub fn rolling_skew(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window and moment only.Apply a rolling skew.
pub fn rolling_kurtosis(self, options: RollingOptionsFixedWindow) -> Expr
Available on crate features rolling_window and moment only.
pub fn rolling_kurtosis(self, options: RollingOptionsFixedWindow) -> Expr
rolling_window and moment only.Apply a rolling skew.
pub fn rolling_map(
self,
f: PlanCallback<Series, Series>,
options: RollingOptionsFixedWindow,
) -> Expr
Available on crate feature rolling_window only.
pub fn rolling_map( self, f: PlanCallback<Series, Series>, options: RollingOptionsFixedWindow, ) -> Expr
rolling_window only.Apply a custom function over a rolling/ moving window of the array. This has quite some dynamic dispatch, so prefer rolling_min, max, mean, sum over this.
pub fn peak_min(self) -> Expr
peaks only.pub fn peak_max(self) -> Expr
peaks only.pub fn rank(self, options: RankOptions, seed: Option<u64>) -> Expr
Available on crate feature rank only.
pub fn rank(self, options: RankOptions, seed: Option<u64>) -> Expr
rank only.Assign ranks to data, dealing with ties appropriately.
pub fn replace<E>(self, old: E, new: E) -> Expr
Available on crate feature replace only.
pub fn replace<E>(self, old: E, new: E) -> Expr
replace only.Replace the given values with other values.
pub fn replace_strict<E>(
self,
old: E,
new: E,
default: Option<E>,
return_dtype: Option<impl Into<DataTypeExpr>>,
) -> Expr
Available on crate feature replace only.
pub fn replace_strict<E>( self, old: E, new: E, default: Option<E>, return_dtype: Option<impl Into<DataTypeExpr>>, ) -> Expr
replace only.Replace the given values with other values.
pub fn cut(
self,
breaks: Vec<f64>,
labels: Option<impl IntoVec<PlSmallStr>>,
left_closed: bool,
include_breaks: bool,
) -> Expr
Available on crate feature cutqcut only.
pub fn cut( self, breaks: Vec<f64>, labels: Option<impl IntoVec<PlSmallStr>>, left_closed: bool, include_breaks: bool, ) -> Expr
cutqcut only.Bin continuous values into discrete categories.
pub fn qcut(
self,
probs: Vec<f64>,
labels: Option<impl IntoVec<PlSmallStr>>,
left_closed: bool,
allow_duplicates: bool,
include_breaks: bool,
) -> Expr
Available on crate feature cutqcut only.
pub fn qcut( self, probs: Vec<f64>, labels: Option<impl IntoVec<PlSmallStr>>, left_closed: bool, allow_duplicates: bool, include_breaks: bool, ) -> Expr
cutqcut only.Bin continuous values into discrete categories based on their quantiles.
pub fn qcut_uniform(
self,
n_bins: usize,
labels: Option<impl IntoVec<PlSmallStr>>,
left_closed: bool,
allow_duplicates: bool,
include_breaks: bool,
) -> Expr
Available on crate feature cutqcut only.
pub fn qcut_uniform( self, n_bins: usize, labels: Option<impl IntoVec<PlSmallStr>>, left_closed: bool, allow_duplicates: bool, include_breaks: bool, ) -> Expr
cutqcut only.Bin continuous values into discrete categories using uniform quantile probabilities.
pub fn rle(self) -> Expr
Available on crate feature rle only.
pub fn rle(self) -> Expr
rle only.Get the lengths of runs of identical values.
pub fn rle_id(self) -> Expr
Available on crate feature rle only.
pub fn rle_id(self) -> Expr
rle only.Similar to rle, but maps values to run IDs.
pub fn diff(self, n: Expr, null_behavior: NullBehavior) -> Expr
Available on crate feature diff only.
pub fn diff(self, n: Expr, null_behavior: NullBehavior) -> Expr
diff only.Calculate the n-th discrete difference between values.
pub fn pct_change(self, n: Expr) -> Expr
Available on crate feature pct_change only.
pub fn pct_change(self, n: Expr) -> Expr
pct_change only.Computes percentage change between values.
pub fn skew(self, bias: bool) -> Expr
Available on crate feature moment only.
pub fn skew(self, bias: bool) -> Expr
moment only.Compute the sample skewness of a data set.
For normally distributed data, the skewness should be about zero. For
uni-modal 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.
see: scipy
pub fn kurtosis(self, fisher: bool, bias: bool) -> Expr
Available on crate feature moment only.
pub fn kurtosis(self, fisher: bool, bias: bool) -> Expr
moment only.Compute the kurtosis (Fisher or Pearson).
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.
pub fn upper_bound(self) -> Expr
pub fn upper_bound(self) -> Expr
Get maximal value that could be hold by this dtype.
pub fn lower_bound(self) -> Expr
pub fn lower_bound(self) -> Expr
Get minimal value that could be hold by this dtype.
pub fn reshape(self, dimensions: &[i64]) -> Expr
dtype-array only.pub fn ewm_mean(self, options: EWMOptions) -> Expr
Available on crate feature ewma only.
pub fn ewm_mean(self, options: EWMOptions) -> Expr
ewma only.Calculate the exponentially-weighted moving average.
pub fn ewm_mean_by(self, times: Expr, half_life: Duration) -> Expr
Available on crate feature ewma_by only.
pub fn ewm_mean_by(self, times: Expr, half_life: Duration) -> Expr
ewma_by only.Calculate the exponentially-weighted moving average by a time column.
pub fn ewm_std(self, options: EWMOptions) -> Expr
Available on crate feature ewma only.
pub fn ewm_std(self, options: EWMOptions) -> Expr
ewma only.Calculate the exponentially-weighted moving standard deviation.
pub fn ewm_var(self, options: EWMOptions) -> Expr
Available on crate feature ewma only.
pub fn ewm_var(self, options: EWMOptions) -> Expr
ewma only.Calculate the exponentially-weighted moving variance.
pub fn any(self, ignore_nulls: bool) -> Expr
pub fn any(self, ignore_nulls: bool) -> Expr
Returns whether any of the values in the column are true.
If ignore_nulls is False, Kleene logic is used to deal with nulls:
if the column contains any null values and no true values, the output
is null.
pub fn all(self, ignore_nulls: bool) -> Expr
pub fn all(self, ignore_nulls: bool) -> Expr
Returns whether all values in the column are true.
If ignore_nulls is False, Kleene logic is used to deal with nulls:
if the column contains any null values and no false values, the output
is null.
pub fn value_counts(
self,
sort: bool,
parallel: bool,
name: &str,
normalize: bool,
) -> Expr
Available on crate feature dtype-struct only.
pub fn value_counts( self, sort: bool, parallel: bool, name: &str, normalize: bool, ) -> Expr
dtype-struct only.Count all unique values and create a struct mapping value to count.
(Note that it is better to turn parallel off in the aggregation context).
The name of the struct field with the counts is given by the parameter name.
pub fn unique_counts(self) -> Expr
Available on crate feature unique_counts only.
pub fn unique_counts(self) -> Expr
unique_counts only.Returns a count of the unique values in the order of appearance.
This method differs from Expr::value_counts in that it does not return the
values, only the counts and might be faster.
pub fn log(self, base: Expr) -> Expr
Available on crate feature log only.
pub fn log(self, base: Expr) -> Expr
log only.Compute the logarithm to a given base.
pub fn log1p(self) -> Expr
Available on crate feature log only.
pub fn log1p(self) -> Expr
log only.Compute the natural logarithm of all elements plus one in the input array.
pub fn exp(self) -> Expr
Available on crate feature log only.
pub fn exp(self) -> Expr
log only.Calculate the exponential of all elements in the input array.
pub fn entropy(self, base: f64, normalize: bool) -> Expr
Available on crate feature log only.
pub fn entropy(self, base: f64, normalize: bool) -> Expr
log only.Compute the entropy as -sum(pk * log(pk)).
where pk are discrete probabilities.
pub fn null_count(self) -> Expr
pub fn null_count(self) -> Expr
Get the null count of the column/group.
pub fn set_sorted_flag(self, sorted: IsSorted) -> Expr
pub fn set_sorted_flag(self, sorted: IsSorted) -> Expr
Set this Series as sorted so that downstream code can use
fast paths for sorted arrays.
§Warning
This can lead to incorrect results if this Series is not sorted!!
Use with care!
pub fn hash(self, k0: u64, k1: u64, k2: u64, k3: u64) -> Expr
Available on crate feature row_hash only.
pub fn hash(self, k0: u64, k1: u64, k2: u64, k3: u64) -> Expr
row_hash only.Compute the hash of every element.
pub fn to_physical(self) -> Expr
pub fn gather_every(self, n: usize, offset: usize) -> Expr
pub fn reinterpret(self, signed: bool) -> Expr
reinterpret only.pub fn extend_constant(self, value: Expr, n: Expr) -> Expr
pub fn str(self) -> StringNameSpace
Available on crate feature strings only.
pub fn str(self) -> StringNameSpace
strings only.Get the string::StringNameSpace
pub fn binary(self) -> BinaryNameSpace
pub fn binary(self) -> BinaryNameSpace
Get the binary::BinaryNameSpace
pub fn dt(self) -> DateLikeNameSpace
Available on crate feature temporal only.
pub fn dt(self) -> DateLikeNameSpace
temporal only.Get the dt::DateLikeNameSpace
pub fn list(self) -> ListNameSpace
pub fn list(self) -> ListNameSpace
Get the list::ListNameSpace
pub fn name(self) -> ExprNameNameSpace
pub fn name(self) -> ExprNameNameSpace
Get the name::ExprNameNameSpace
pub fn arr(self) -> ArrayNameSpace
Available on crate feature dtype-array only.
pub fn arr(self) -> ArrayNameSpace
dtype-array only.Get the array::ArrayNameSpace.
pub fn cat(self) -> CategoricalNameSpace
Available on crate feature dtype-categorical only.
pub fn cat(self) -> CategoricalNameSpace
dtype-categorical only.Get the CategoricalNameSpace.
pub fn ext(self) -> ExtensionNameSpace
Available on crate feature dtype-extension only.
pub fn ext(self) -> ExtensionNameSpace
dtype-extension only.Get the extension::ExtensionNameSpace.
pub fn struct_(self) -> StructNameSpace
Available on crate feature dtype-struct only.
pub fn struct_(self) -> StructNameSpace
dtype-struct only.Get the struct_::StructNameSpace.
pub fn meta(self) -> MetaNameSpace
Available on crate feature meta only.
pub fn meta(self) -> MetaNameSpace
meta only.Get the meta::MetaNameSpace
Trait Implementations§
§impl<'de> Deserialize<'de> for Expr
impl<'de> Deserialize<'de> for Expr
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Expr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Expr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl<'a> IntoIterator for &'a Expr
impl<'a> IntoIterator for &'a Expr
§impl Serialize for Expr
impl Serialize for Expr
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
§impl TreeWalker for Expr
impl TreeWalker for Expr
type Arena = ()
fn apply_children<F>( &self, op: &mut F, arena: &<Expr as TreeWalker>::Arena, ) -> Result<VisitRecursion, PolarsError>
fn map_children<F>( self, f: &mut F, _arena: &mut <Expr as TreeWalker>::Arena, ) -> Result<Expr, PolarsError>
§fn visit<V>(
&self,
visitor: &mut V,
arena: &Self::Arena,
) -> Result<VisitRecursion, PolarsError>where
V: Visitor<Node = Self, Arena = Self::Arena>,
fn visit<V>(
&self,
visitor: &mut V,
arena: &Self::Arena,
) -> Result<VisitRecursion, PolarsError>where
V: Visitor<Node = Self, Arena = Self::Arena>,
fn rewrite<R>(
self,
rewriter: &mut R,
arena: &mut Self::Arena,
) -> Result<Self, PolarsError>where
R: RewritingVisitor<Node = Self, Arena = Self::Arena>,
impl Eq for Expr
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl !Freeze for Expr
impl !RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl !UnwindSafe for Expr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Key for Twhere
T: Clone,
impl<T> Key for Twhere
T: Clone,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString]. Read more§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.