Combee is a flexible data analysis library written in pure Rust inspired by pandas (python).
Run in a Rust project directory:
bash
cargo add combee
1) Below an example of loading a CSV file, filtering the dataset, and applying a function to each row:
(dataset.csv)
csv
name,age
Daniel,26
Sergio,30
Leticia,22
(main.rs) ```rust use std::fmt::Display; use serde::{Serialize, Deserialize};
use combee;
struct Data { name: String, age: u32 }
struct Message { message: String }
impl Display for Message { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.message) } }
fn main() { let df = combee::readcsv::(String::from("dataset.csv")).unwrap(); let dffiltered = df.filter(|row| row.age < 27); let dfmessage = dffiltered.apply(|row| Message { message: format!("Hello {} with {} years!", row.name, row.age)}); let messages = df_message.take(2);
println!("{}", messages[0]);
println!("{}", messages[1]);
} ```
2) An example of groupby with aggregation
(main.rs) ```rust use serde::{Serialize, Deserialize};
use combee; use combee::functions::{mean, sum, count};
struct Data { name: String, age: u32 }
fn main() { let df = combee::read_csv::(String::from("dataset.csv")).unwrap();
let stats = df.groupby(|_| 1).agg(|_, g|
(count(g), mean(g, |x| x.age), sum(g, |x| x.age))
).head(1);
println("{:?}", stats);
} ```
Daniel Santana: Made with Love.\ ali5h: Code to deserialize parquet row link.