In Rust, using Polars, I am writing a custom function to be used within apply/map. This works well:
fn capita(x: Series) -> Result<Series> {
let y = x
.utf8()
.unwrap()
.par_iter() //ParallelIterator
However, if my Series was of type f64, then this doesn't work:
fn other_fn(x: Series) -> Result<Series> {
let y = x
.f64()
.unwrap()
.par_iter() // <--- no method par_iter found for reference ChunkedArray<Float64Type>
Is there a possible workaround? Looking at utf8.rs I need something like that but for Float64Chunked type.
Many thanks
EDIT I think this workaround has worked, although turned out to be slower, AND giving an unexpected result. using par_bridge:
pub fn pa_fa(s: &mut [Series])->Result<Series>{
let u = s[2].f64()?;
let n = s[1].f64()?;
let n_iter = n.into_iter();
let c: Vec<f64> = n_iter.zip(u).par_bridge().map(
// ignore this line let c: Vec<f64> = n_iter.zip(u).map(
|(n,u)|{
n.unwrap().powf(1.777)*u.unwrap().sqrt()
}
).collect();
Ok(Series::new("Ant", c))