Is there a simple way to apply a function to a Polars DataFrame
in Rust?
If my function and dataframe is the following for example:
fn double(x:i32) -> i32 {
x*2
}
let s0 = Series::new("id", &[1, 2, 3]);
let s1 = Series::new("cost", &[10, 20, 30]);
let mut df = DataFrame::new(vec![s0, s1])?;
Here I'd like to do something that looks like:
df.apply("cost", |x| double(x))
Using pandas, I achieve the same with:
df["cost"] = df["cost"].apply(lambda x: double(x))
I'd love to know the equivalent way to apply a function over a column like this!