Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/pyo3-polars/pyo3-polars-derive/tests/01.rs
6939 views
1
use polars_core::error::PolarsResult;
2
use polars_core::prelude::*;
3
use polars_plan::plans::FieldsMapper;
4
use pyo3_polars_derive::polars_expr;
5
6
fn horizontal_product_output(input_fields: &[Field]) -> PolarsResult<Field> {
7
FieldsMapper::new(input_fields).map_to_supertype()
8
}
9
10
#[polars_expr(output_type_func=horizontal_product_output)]
11
fn horizontal_product(series: &[Series], kwargs: Option<&str>) -> PolarsResult<Series> {
12
let _ = kwargs;
13
14
let mut acc = series[0].clone();
15
for s in &series[1..] {
16
acc = (&acc * s)?
17
}
18
Ok(acc)
19
}
20
21
fn main() {}
22
23