Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/plans/aexpr/function_expr/rolling.rs
7889 views
1
use super::*;
2
3
#[derive(Clone, PartialEq, Debug, Hash)]
4
#[cfg_attr(feature = "ir_serde", derive(serde::Serialize, serde::Deserialize))]
5
pub enum IRRollingFunction {
6
Min,
7
Max,
8
Mean,
9
Sum,
10
Quantile,
11
Var,
12
Std,
13
Rank,
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 IRRollingFunction {
28
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
29
use IRRollingFunction::*;
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
Rank => "rank",
40
#[cfg(feature = "moment")]
41
Skew => "skew",
42
#[cfg(feature = "moment")]
43
Kurtosis => "kurtosis",
44
#[cfg(feature = "cov")]
45
CorrCov { is_corr, .. } => {
46
if *is_corr {
47
"corr"
48
} else {
49
"cov"
50
}
51
},
52
Map(_) => "map",
53
};
54
55
write!(f, "rolling_{name}")
56
}
57
}
58
59