Path: blob/main/crates/polars-plan/src/dsl/statistics.rs
8430 views
use super::*;12impl Expr {3/// Standard deviation of the values of the Series.4pub fn std(self, ddof: u8) -> Self {5AggExpr::Std(Arc::new(self), ddof).into()6}78/// Variance of the values of the Series.9pub fn var(self, ddof: u8) -> Self {10AggExpr::Var(Arc::new(self), ddof).into()11}1213/// Reduce groups to minimal value.14pub fn min(self) -> Self {15AggExpr::Min {16input: Arc::new(self),17propagate_nans: false,18}19.into()20}2122/// Reduce groups to maximum value.23pub fn max(self) -> Self {24AggExpr::Max {25input: Arc::new(self),26propagate_nans: false,27}28.into()29}3031/// Get minimum value, ordered by another expression.32pub fn min_by(self, by: Self) -> Self {33Expr::n_ary(FunctionExpr::MinBy, vec![self, by])34}3536/// Get maximum value, ordered by another expression.37pub fn max_by(self, by: Self) -> Self {38Expr::n_ary(FunctionExpr::MaxBy, vec![self, by])39}4041/// Reduce groups to minimal value.42pub fn nan_min(self) -> Self {43AggExpr::Min {44input: Arc::new(self),45propagate_nans: true,46}47.into()48}4950/// Reduce groups to maximum value.51pub fn nan_max(self) -> Self {52AggExpr::Max {53input: Arc::new(self),54propagate_nans: true,55}56.into()57}5859/// Reduce groups to the mean value.60pub fn mean(self) -> Self {61AggExpr::Mean(Arc::new(self)).into()62}6364/// Reduce groups to the median value.65pub fn median(self) -> Self {66AggExpr::Median(Arc::new(self)).into()67}6869/// Reduce groups to the sum of all the values.70pub fn sum(self) -> Self {71AggExpr::Sum(Arc::new(self)).into()72}7374/// Compute the histogram of a dataset.75#[cfg(feature = "hist")]76pub fn hist(77self,78bins: Option<Expr>,79bin_count: Option<usize>,80include_category: bool,81include_breakpoint: bool,82) -> Self {83let mut input = vec![self];84input.extend(bins);8586Expr::n_ary(87FunctionExpr::Hist {88bin_count,89include_category,90include_breakpoint,91},92input,93)94}95}969798