polars-row-derive

Crates.iopolars-row-derive
lib.rspolars-row-derive
version0.1.0
sourcesrc
created_at2024-04-16 23:40:24.221266
updated_at2024-04-16 23:40:24.221266
descriptionMacro to help convert an interator of structs into a DataFrame
homepagehttps://github.com/andyquinterom/polars-row-derive
repositoryhttps://github.com/andyquinterom/polars-row-derive
max_upload_size
id1210836
size6,973
Andrés Felipe Quintero Moreano (andyquinterom)

documentation

README

polars-row-derive

This is a simple crate that allows you derive a custom trait to convert an iterator over your structs into a DataFrame from the polars crate.

Example

use polars_row_derive::IterToDataFrame;

#[derive(IterToDataFrame)]
pub struct TestStruct {
    a: i32,
    b: i32,
}

// Dynamic size iterator
let df = (0..10)
    .filter(|i| i % 2 == 0)
    .map(|i| TestStruct { a: i, b: i })
    .to_dataframe_dyn()
    .unwrap();

assert_eq!(df.shape(), (5, 2));

// Fixed size iterator
let df = (0..10)
    .map(|i| TestStruct { a: i, b: i })
    .to_dataframe()
    .unwrap();

assert_eq!(df.shape(), (10, 2));
Commit count: 2

cargo fmt