Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-python/src/functions/aggregation.rs
7889 views
1
use polars::lazy::dsl;
2
use pyo3::prelude::*;
3
4
use crate::PyExpr;
5
use crate::error::PyPolarsErr;
6
use crate::expr::ToExprs;
7
8
#[pyfunction]
9
pub 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]
16
pub 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]
23
pub 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]
30
pub 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]
37
pub 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]
44
pub 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
}
49
50