Crates.io | polars-row-derive |
lib.rs | polars-row-derive |
version | 0.1.0 |
source | src |
created_at | 2024-04-16 23:40:24.221266 |
updated_at | 2024-04-16 23:40:24.221266 |
description | Macro to help convert an interator of structs into a DataFrame |
homepage | https://github.com/andyquinterom/polars-row-derive |
repository | https://github.com/andyquinterom/polars-row-derive |
max_upload_size | |
id | 1210836 |
size | 6,973 |
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.
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));