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
6940 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
#[cfg(feature = "moment")]
15
Skew,
16
#[cfg(feature = "moment")]
17
Kurtosis,
18
#[cfg(feature = "cov")]
19
CorrCov {
20
corr_cov_options: RollingCovOptions,
21
// Whether is Corr or Cov
22
is_corr: bool,
23
},
24
Map(PlanCallback<Series, Series>),
25
}
26
27
impl Display for RollingFunction {
28
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
29
use RollingFunction::*;
30
31
let name = match self {
32
Min => "min",
33
Max => "max",
34
Mean => "mean",
35
Sum => "rsum",
36
Quantile => "quantile",
37
Var => "var",
38
Std => "std",
39
#[cfg(feature = "moment")]
40
Skew => "skew",
41
#[cfg(feature = "moment")]
42
Kurtosis => "kurtosis",
43
#[cfg(feature = "cov")]
44
CorrCov { is_corr, .. } => {
45
if *is_corr {
46
"corr"
47
} else {
48
"cov"
49
}
50
},
51
Map(_) => "map",
52
};
53
54
write!(f, "rolling_{name}")
55
}
56
}
57
58