Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/statistics.rs
6939 views
1
use super::*;
2
3
impl Expr {
4
/// Standard deviation of the values of the Series.
5
pub fn std(self, ddof: u8) -> Self {
6
AggExpr::Std(Arc::new(self), ddof).into()
7
}
8
9
/// Variance of the values of the Series.
10
pub fn var(self, ddof: u8) -> Self {
11
AggExpr::Var(Arc::new(self), ddof).into()
12
}
13
14
/// Reduce groups to minimal value.
15
pub fn min(self) -> Self {
16
AggExpr::Min {
17
input: Arc::new(self),
18
propagate_nans: false,
19
}
20
.into()
21
}
22
23
/// Reduce groups to maximum value.
24
pub fn max(self) -> Self {
25
AggExpr::Max {
26
input: Arc::new(self),
27
propagate_nans: false,
28
}
29
.into()
30
}
31
32
/// Reduce groups to minimal value.
33
pub fn nan_min(self) -> Self {
34
AggExpr::Min {
35
input: Arc::new(self),
36
propagate_nans: true,
37
}
38
.into()
39
}
40
41
/// Reduce groups to maximum value.
42
pub fn nan_max(self) -> Self {
43
AggExpr::Max {
44
input: Arc::new(self),
45
propagate_nans: true,
46
}
47
.into()
48
}
49
50
/// Reduce groups to the mean value.
51
pub fn mean(self) -> Self {
52
AggExpr::Mean(Arc::new(self)).into()
53
}
54
55
/// Reduce groups to the median value.
56
pub fn median(self) -> Self {
57
AggExpr::Median(Arc::new(self)).into()
58
}
59
60
/// Reduce groups to the sum of all the values.
61
pub fn sum(self) -> Self {
62
AggExpr::Sum(Arc::new(self)).into()
63
}
64
65
/// Compute the histogram of a dataset.
66
#[cfg(feature = "hist")]
67
pub fn hist(
68
self,
69
bins: Option<Expr>,
70
bin_count: Option<usize>,
71
include_category: bool,
72
include_breakpoint: bool,
73
) -> Self {
74
let mut input = vec![self];
75
input.extend(bins);
76
77
Expr::n_ary(
78
FunctionExpr::Hist {
79
bin_count,
80
include_category,
81
include_breakpoint,
82
},
83
input,
84
)
85
}
86
}
87
88