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.rs
8393 views
1
use super::*;
2
3
#[derive(Clone, PartialEq, Debug, Hash)]
4
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
6
pub enum RollingFunction {
7
Min,
8
Max,
9
Mean,
10
Sum,
11
Quantile,
12
Var,
13
Std,
14
Rank,
15
#[cfg(feature = "moment")]
16
Skew,
17
#[cfg(feature = "moment")]
18
Kurtosis,
19
#[cfg(feature = "cov")]
20
CorrCov {
21
corr_cov_options: RollingCovOptions,
22
// Whether is Corr or Cov
23
is_corr: bool,
24
},
25
Map(PlanCallback<Series, Series>),
26
}
27
28
impl Display for RollingFunction {
29
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
30
use RollingFunction::*;
31
32
let name = match self {
33
Min => "min",
34
Max => "max",
35
Mean => "mean",
36
Sum => "rsum",
37
Quantile => "quantile",
38
Var => "var",
39
Std => "std",
40
Rank => "rank",
41
#[cfg(feature = "moment")]
42
Skew => "skew",
43
#[cfg(feature = "moment")]
44
Kurtosis => "kurtosis",
45
#[cfg(feature = "cov")]
46
CorrCov { is_corr, .. } => {
47
if *is_corr {
48
"corr"
49
} else {
50
"cov"
51
}
52
},
53
Map(_) => "map",
54
};
55
56
write!(f, "rolling_{name}")
57
}
58
}
59
60