polars_plan/dsl/functions/
index.rs

1use super::*;
2
3/// Find the indexes that would sort these series in order of appearance.
4///
5/// That means that the first `Series` will be used to determine the ordering
6/// until duplicates are found. Once duplicates are found, the next `Series` will
7/// be used and so on.
8#[cfg(feature = "range")]
9pub fn arg_sort_by<E: AsRef<[Expr]>>(by: E, sort_options: SortMultipleOptions) -> Expr {
10    let e = &by.as_ref()[0];
11    let name = expr_output_name(e).unwrap();
12    int_range(lit(0 as IdxSize), len().cast(IDX_DTYPE), 1, IDX_DTYPE)
13        .sort_by(by, sort_options)
14        .alias(name)
15}
16
17#[cfg(feature = "arg_where")]
18/// Get the indices where `condition` evaluates `true`.
19pub fn arg_where<E: Into<Expr>>(condition: E) -> Expr {
20    let condition = condition.into();
21    Expr::Function {
22        input: vec![condition],
23        function: FunctionExpr::ArgWhere,
24        options: FunctionOptions {
25            collect_groups: ApplyOptions::GroupWise,
26            ..Default::default()
27        },
28    }
29}