Polars (WIP)
Blazingly fast in memory DataFrames in Rust
Polars is a DataFrames library implemented in Rust, using Apache Arrow as backend. It's focus is being a fast in memory DataFrame library that only support core functionality.
Performance
GroupBy
Functionality
Series
- cast
- take by index/ boolean mask
- limit
- Rust iterators! (So any function you can think of)
- append
- aggregation: min, max, sum
- arithmetic
- comparison
- find
- sorting
DataFrame
- take by index/ boolean mask
- limit
- join: inner, left
- column ops: drop, select, rename
- group by: min, max, sum, mean, count
- concat (horizontal)
- read csv
- write csv
- write json
- read json
- write parquet
- read parquet
- sorting
Data types
- null
- boolean
- u32
- i32
- i64
- f32
- f64
- utf-8
- date
- time
Examples
use polars::prelude::*;
// Create first df.
let s0 = Series::init("days", [0, 1, 2, 3, 4].as_ref());
let s1 = Series::init("temp", [22.1, 19.9, 7., 2., 3.].as_ref());
let temp = DataFrame::new_from_columns(vec![s0, s1]).unwrap();
// Create second df.
let s0 = Series::init("days", [1, 2].as_ref());
let s1 = Series::init("rain", [0.1, 0.2].as_ref());
let rain = DataFrame::new_from_columns(vec![s0, s1]).unwrap();
// Left join on days column.
let joined = temp.left_join(&rain, "days", "days");
println!("{}", joined.unwrap())
days temp rain
i32 f64 f64
--- --- ---
0 22.1 null
1 19.9 0.1
2 7 0.2
3 2 null
4 3 null
Arithmetic
use polars::prelude::*;
let s: Series = [1, 2, 3].iter().collect();
let s_squared = &s * &s;
Custom functions
use polars::prelude::*;
let s: Series = [1, 2, 3].iter().collect();
let s_squared: Series = s.i32()
.expect("datatype mismatch")
.into_iter()
.map(|optional_v| {
match optional_v {
Some(v) => Some(v * v),
None => None, // null value
}
}).collect();