Enum polars::prelude::Expr [−][src]
pub enum Expr {}Show variants
Alias(Box<Expr, Global>, Arc<String>), Column(Arc<String>), Literal(LiteralValue), BinaryExpr { left: Box<Expr, Global>, op: Operator, right: Box<Expr, Global>, }, Not(Box<Expr, Global>), IsNotNull(Box<Expr, Global>), IsNull(Box<Expr, Global>), Cast { expr: Box<Expr, Global>, data_type: DataType, }, Sort { expr: Box<Expr, Global>, reverse: bool, }, Take { expr: Box<Expr, Global>, idx: Box<Expr, Global>, }, SortBy { expr: Box<Expr, Global>, by: Box<Expr, Global>, reverse: bool, }, Agg(AggExpr), Ternary { predicate: Box<Expr, Global>, truthy: Box<Expr, Global>, falsy: Box<Expr, Global>, }, Function { input: Vec<Expr, Global>, function: NoEq<Arc<dyn SeriesUdf + 'static>>, output_type: Option<DataType>, collect_groups: bool, }, Shift { input: Box<Expr, Global>, periods: i64, }, Reverse(Box<Expr, Global>), Duplicated(Box<Expr, Global>), IsUnique(Box<Expr, Global>), Explode(Box<Expr, Global>), Filter { input: Box<Expr, Global>, by: Box<Expr, Global>, }, Window { function: Box<Expr, Global>, partition_by: Vec<Expr, Global>, order_by: Option<Box<Expr, Global>>, }, Wildcard, Slice { input: Box<Expr, Global>, offset: i64, length: usize, }, BinaryFunction { input_a: Box<Expr, Global>, input_b: Box<Expr, Global>, function: NoEq<Arc<dyn SeriesBinaryUdf + 'static>>, output_field: NoEq<Arc<dyn BinaryUdfOutputField + 'static>>, }, Except(Box<Expr, Global>),
Expand description
Queries consists of multiple expressions.
Variants
Literal(LiteralValue)
Agg(AggExpr)
A ternary operation if true then “foo” else “bar”
Show fields
Show fields
See postgres window functions
Show fields
Show fields
Show fields
Can be used in a select statement to exclude a column from selection
Implementations
Run is_not_null operation on Expr
.
Get the group indexes of the group by operation.
Get the first index of unique values of this expression.
Get the index values that would sort this expression.
Sort in increasing order. See the eager implementation.
Can be used in default
and aggregation
context.
Apply a function/closure once the logical plan get executed.
This function is very similar to apply, but differs in how it handles aggregations.
map
should be used for operations that are independent of groups, e.g.multiply * 2
, orraise to the power
apply
should 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.
Apply a function/closure over the groups. This should only be used in a groupby 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.
map
should be used for operations that are independent of groups, e.g.multiply * 2
, orraise to the power
apply
should be used for operations that work on a group of data. e.g.sum
,count
, etc.
Get mask of infinite values if dtype is Float
Get inverse mask of NaN values if dtype is Float
Shift the values in the array by some period. See the eager implementation.
Shift the valus in the array by some period and fill the resulting empty values.
Get an array with the cumulative sum computed at every element
Get an array with the cumulative min computed at every element
Get an array with the cumulative max computed at every element
Round underlying floating point array to given decimal numbers.
Apply window function over a subgroup. This is similar to a groupby + 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() -> Result<()> { 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(vec![col("groups")]), ]) .collect()?; dbg!(&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 │
╰────────┴────────╯
Shift the values in the array by some period. See the eager implementation.
Count the values of the Series or Get counts of the group by operation.
Get a mask of duplicated values
Filter a single column Should be used in aggregation context. If you want to filter on a DataFrame level, use LazyFrame::filter
Check if the values of the left expression are in the lists of the right expr.
Get the ordinal_day of a Date32/Date64
Get the nanosecond of a Time64
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Expr
impl !UnwindSafe for Expr
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V