polars_python/functions/
aggregation.rs1use polars::lazy::dsl;
2use pyo3::prelude::*;
3
4use crate::PyExpr;
5use crate::error::PyPolarsErr;
6use crate::expr::ToExprs;
7
8#[pyfunction]
9pub fn all_horizontal(exprs: Vec<PyExpr>) -> PyResult<PyExpr> {
10 let exprs = exprs.to_exprs();
11 let e = dsl::all_horizontal(exprs).map_err(PyPolarsErr::from)?;
12 Ok(e.into())
13}
14
15#[pyfunction]
16pub fn any_horizontal(exprs: Vec<PyExpr>) -> PyResult<PyExpr> {
17 let exprs = exprs.to_exprs();
18 let e = dsl::any_horizontal(exprs).map_err(PyPolarsErr::from)?;
19 Ok(e.into())
20}
21
22#[pyfunction]
23pub fn max_horizontal(exprs: Vec<PyExpr>) -> PyResult<PyExpr> {
24 let exprs = exprs.to_exprs();
25 let e = dsl::max_horizontal(exprs).map_err(PyPolarsErr::from)?;
26 Ok(e.into())
27}
28
29#[pyfunction]
30pub fn min_horizontal(exprs: Vec<PyExpr>) -> PyResult<PyExpr> {
31 let exprs = exprs.to_exprs();
32 let e = dsl::min_horizontal(exprs).map_err(PyPolarsErr::from)?;
33 Ok(e.into())
34}
35
36#[pyfunction]
37pub fn sum_horizontal(exprs: Vec<PyExpr>, ignore_nulls: bool) -> PyResult<PyExpr> {
38 let exprs = exprs.to_exprs();
39 let e = dsl::sum_horizontal(exprs, ignore_nulls).map_err(PyPolarsErr::from)?;
40 Ok(e.into())
41}
42
43#[pyfunction]
44pub fn mean_horizontal(exprs: Vec<PyExpr>, ignore_nulls: bool) -> PyResult<PyExpr> {
45 let exprs = exprs.to_exprs();
46 let e = dsl::mean_horizontal(exprs, ignore_nulls).map_err(PyPolarsErr::from)?;
47 Ok(e.into())
48}