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