polars_plan/dsl/
statistics.rs1use super::*;
2
3impl Expr {
4 pub fn std(self, ddof: u8) -> Self {
6 AggExpr::Std(Arc::new(self), ddof).into()
7 }
8
9 pub fn var(self, ddof: u8) -> Self {
11 AggExpr::Var(Arc::new(self), ddof).into()
12 }
13
14 pub fn min(self) -> Self {
16 AggExpr::Min {
17 input: Arc::new(self),
18 propagate_nans: false,
19 }
20 .into()
21 }
22
23 pub fn max(self) -> Self {
25 AggExpr::Max {
26 input: Arc::new(self),
27 propagate_nans: false,
28 }
29 .into()
30 }
31
32 pub fn nan_min(self) -> Self {
34 AggExpr::Min {
35 input: Arc::new(self),
36 propagate_nans: true,
37 }
38 .into()
39 }
40
41 pub fn nan_max(self) -> Self {
43 AggExpr::Max {
44 input: Arc::new(self),
45 propagate_nans: true,
46 }
47 .into()
48 }
49
50 pub fn mean(self) -> Self {
52 AggExpr::Mean(Arc::new(self)).into()
53 }
54
55 pub fn median(self) -> Self {
57 AggExpr::Median(Arc::new(self)).into()
58 }
59
60 pub fn sum(self) -> Self {
62 AggExpr::Sum(Arc::new(self)).into()
63 }
64
65 #[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}