Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/function_expr/rolling_by.rs
8412 views
1
use super::*;
2
3
#[derive(Clone, PartialEq, Debug)]
4
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
6
pub enum RollingFunctionBy {
7
MinBy,
8
MaxBy,
9
MeanBy,
10
SumBy,
11
QuantileBy,
12
VarBy,
13
StdBy,
14
RankBy,
15
}
16
17
impl Display for RollingFunctionBy {
18
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
19
use RollingFunctionBy::*;
20
21
let name = match self {
22
MinBy => "rolling_min_by",
23
MaxBy => "rolling_max_by",
24
MeanBy => "rolling_mean_by",
25
SumBy => "rolling_sum_by",
26
QuantileBy => "rolling_quantile_by",
27
VarBy => "rolling_var_by",
28
StdBy => "rolling_std_by",
29
RankBy => "rolling_rank_by",
30
};
31
32
write!(f, "{name}")
33
}
34
}
35
36
impl Hash for RollingFunctionBy {
37
fn hash<H: Hasher>(&self, state: &mut H) {
38
std::mem::discriminant(self).hash(state);
39
}
40
}
41
42