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 if let Some(bins) = bins {
76 input.push(bins)
77 }
78
79 Expr::Function {
80 input,
81 function: FunctionExpr::Hist {
82 bin_count,
83 include_category,
84 include_breakpoint,
85 },
86 options: FunctionOptions {
87 collect_groups: ApplyOptions::GroupWise,
88 ..Default::default()
89 },
90 }
91 }
92}