How to Use polars for DataFrames in Rust

Install the polars crate via Cargo and use the prelude to create DataFrames from Series vectors.

Add the polars crate to your Cargo.toml and import the prelude to create DataFrames.

[dependencies]
polars = { version = "0.40", features = ["lazy"] }
use polars::prelude::*;

fn main() -> PolarsResult<()> {
    let df = DataFrame::new(vec![
        Series::new("foo", &[1, 2, 3]),
        Series::new("bar", &["a", "b", "c"]),
    ])?;
    println!("{df}");
    Ok(())
}