I am a little confused. Creating a polars series with a vector of "simple" options
Vec<Option<f64>>
works ... but a vector of options with complex values (e.g. vectors / arrays) does not?!
Vec<Option<Vec<f64>>>
Why? ... and how to make it work?
use polars::prelude::*;
fn main() {
// This does NOT work
let v = vec![Some(vec![0.123, 67.12]), None, Some(vec![2.123, 44.98])];
// This does NOT work
let v = vec![Some([0.123, 67.12]), None, Some([2.123, 44.98])];
// This does work
let v = vec![Some(0.123), None, Some(44.98)];
let s = Series::new("got nulls", v);
println!("{:?}", s)
}
This is the error message I get when I try to make let v = vec![Some(vec![0.123, 67.12]), None, Some(vec![2.123, 44.98])];
into a Series:
error[E0277]: the trait bound `polars::prelude::Series: polars::prelude::NamedFrom<Vec<Option<Vec<{float}>>>, _>` is not satisfied
--> src\main.rs:13:38
|
13 | let s = Series::new("got nulls", v);
| ----------- ^ the trait `polars::prelude::NamedFrom<Vec<Option<Vec<{float}>>>, _>` is not implemented for `polars::prelude::Series`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `polars::prelude::NamedFrom<T, Phantom>`:
<polars::prelude::Series as polars::prelude::NamedFrom<&polars::prelude::Series, str>>
<polars::prelude::Series as polars::prelude::NamedFrom<T, ListType>>
<polars::prelude::Series as polars::prelude::NamedFrom<T, T>>
<polars::prelude::Series as polars::prelude::NamedFrom<T, [&'a str]>>
<polars::prelude::Series as polars::prelude::NamedFrom<T, [AnyValue<'a>]>>
<polars::prelude::Series as polars::prelude::NamedFrom<T, [Cow<'a, str>]>>
<polars::prelude::Series as polars::prelude::NamedFrom<T, [NaiveDateTime]>>
<polars::prelude::Series as polars::prelude::NamedFrom<T, [NaiveDate]>>
and 37 others