Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/functions/index.rs
6940 views
1
use 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")]
9
pub 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`.
19
pub fn arg_where<E: Into<Expr>>(condition: E) -> Expr {
20
condition.into().map_unary(FunctionExpr::ArgWhere)
21
}
22
23