Skip to content

Combee is a flexible data analysis library written in pure Rust inspired by pandas (python).

License

Notifications You must be signed in to change notification settings

DanielSanRocha/combee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Combee

Combee is a strong typed data analysis library written in pure Rust inspired by pandas (python).

Installation

Run in a Rust project directory:

cargo add combee

Examples

  1. Check the notebook using evcxr_jupyter on notebooks/analysis.ipynb to an example of analysis of dataset.

  2. Below an example of loading a CSV file, filtering the dataset, and applying a function to each row:

(dataset.csv)

name,age
Daniel,26
Sergio,30
Leticia,22

(main.rs)

use serde::{Serialize, Deserialize};
use combee::{read_csv, dataframe::DataFrame};

#[derive(Clone, Deserialize, Serialize)]
struct Data {
    name: String,
    age: u32
}

let df = read_csv::<Data>(String::from("../tests/fixtures/basic.csv")).unwrap();
let df_filtered: DataFrame<Data> = df.filter(|row| row.age < 27);
let df_message: DataFrame<String> = df_filtered.apply(|row| format!("Hello {} with {} years!", row.name, row.age));
let messages = df_message.take(2);

println!("{}", messages[0]);
println!("{}", messages[1]);
  1. An example of groupby with aggregation

(main.rs)

use serde::{Serialize, Deserialize};
use combee::{read_csv, functions::{avg, sum, count, all}};

#[derive(Clone, Deserialize, Serialize)]
struct Data {
    name: String,
    age: u32
}

fn main() {
    let df = read_csv::<Data>(String::from("dataset.csv")).unwrap();

    let stats = df.groupby(all).agg(|_, g|
        (count(g), avg(g, |x| x.age), sum(g, |x| x.age))
    ).head(1);

    println("{:?}", stats);
}

Acknowledgments

Daniel Santana: Made with Love 💗.
ali5h: Code to deserialize parquet row link.

About

Combee is a flexible data analysis library written in pure Rust inspired by pandas (python).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published