I am experienced in Polars' Python package and just starting to use the Rust crate.
In a function I want to return a DataFrame that almost certainly has columns with missing values. My current approach is to create vectors with sentinel values as a starting point for a DataFrame and then I hope to replace those values with nulls.
But I'm not having much success.
I can create the vectors and DataFrame with something like this
let mut a_vec: Vec<i64> = Vec::with_capacity(10);
for i in 0..10 {
if <condition> {
a_vec[i] = 1;
} else {
a_vec[i] = std::i64::MAX
}
}
let mut df: DataFrame = df!("a" => a_vec).unwrap();
Now I want to replace std::i64::MAX with null.
In Python Polars I can run use the replace method, but I haven't found a (good) way to this in Rust.
If there is a better way to do this where I can avoid the sentinel values I'm all ears.
The proper way is to create a vector of
Options:You can also use chunked array builders, it should be more efficient: