Rust polars dataframe has not attribute "to_ndarray"

Viewed 466

Here we go again with another problem I can't solve, although it sound so easy.

I am following Rust polars documentation about dataframes: https://docs.rs/polars/0.14.2/polars/frame/struct.DataFrame.html I am trying to simply implement the easies thing they wrote, namely create a dataframe and convert to 2D array with to_ndarray:

use polars::prelude::*;
use polars_core::prelude::*;
use polars::frame::DataFrame;

fn main() {
    println!("Defining a dataframe");
    let a = UInt32Chunked::new_from_slice("a", &[1, 2, 3]).into_series();
    let b = Float64Chunked::new_from_slice("b", &[10., 8., 6.]).into_series();
    
    let df = DataFrame::new(vec![a, b]).unwrap();
    let ndarray = df.to_ndarray::<Float64Type>().unwrap();
    println!("{:?}", ndarray);
}

When I am trying to run this code I have the following error:

error[E0599]: no method named `to_ndarray` found for struct `DataFrame` in the current scope
  --> src/main.rs:42:22
   |
42 |     let ndarray = df.to_ndarray::<Float64Type>().unwrap();
   |                      ^^^^^^^^^^ method not found in `DataFrame`

What should I import to use to_ndarray?

0 Answers
Related