Suppose I wanted to add into my dataframe a column for arrays. This can be done easily in the python implementation by specifying the schema at construction. Here is some code to show off my issue
fn main() {
let ArrayType = DataType::Array(Box::new(DataType::Array(Box::new(DataType::Int64), 2), 2)
let mut s1 = Series::new_empty("test".into(), &ArrayType);
...
// I can't add data to this array
let test_data = Array2::from_shape_vec((2,2), vec![1,2,3,4]).unwrap();
// this can't be added directly, so I tried iterating over it and using list builders
// but i must be doing something wrong
}
It seams like I need to use a chunked array builder, but I have not been able to find the correct syntax for doing this with arrays. I can construct a list of lists, but I want to take advantage of the enforced sizing from the array data type.
I have tried list primitive chunk builders
let mut builder = ListPrimitiveChunkedBuilder::new(name, capacity, values_capacity, inner_type);
But elements constructed this way cannot be pushed into a series with the array data type. The documentation is lacking on how to add lists or arrays into Series, Column, or DataFrames.
This post is incredibly unhelpful as the answer is "you just can't do this in rust". If this where the case then why does the official documentation suggest that this is something you should be able to do in rust. There are also no issues about why this has not yet been implemented.
Box::newdoesn't take 2 parameters, did you miss some parentheses?Array2?polars, it's "just a dump of the internals" according to a polars dev. That means not everything doable in Python necessarily has to be doable similarly in Rust and just because a documentation page exists doesn't mean it's directly supported in Rust either.