Dataframe in rust 🦀
+-----------+------+-----------+
| strangs | nums | null nums |
+-----------+------+-----------+
| sugar | 0 | -10 |
| sweets | 1 | Null |
| candy pop | 2 | 200 |
| caramel | 3 | 400 |
| chocolate | 4 | 777 |
+-----------+------+-----------+
Import
use *;
Create
Create from rows
using the row!
macro
let df = from_rows
.unwrap;
Create from csv
With ToRow proc-macro
let df = .unwrap;
Or implement ToRow manually
With null values
let df = from_rows
.unwrap;
With timestamp
let df = from_rows
.unwrap;
Supported types
- String
- Int
- Uint
- Float
- Bool
- Option/Null
- chrono::NaiveDateTime
Display
df.print;
Extend
Add column
df.add_col.unwrap;
Add row
df.add_row.unwrap;
Concat
df.concat
.unwrap;
Join
// join(other_df, (left_col, right_col))
let result_df = df
.join
.unwrap;
Slice
By index
// to_dataframe copies DataSlice into new Dataframe
df.slice.unwrap.to_dataframe;
By column
df.col_slice
.unwrap
.to_dataframe;
Get cell
// (row_index, col_name)
let cell = df.cell.unwrap;
Filter
Simple
let df = df.filter.unwrap;
Complex
Nest as many and/or/exp as needed
let df = df
.filter
.unwrap;
Supported expression operations:
eq()
equalneq()
not equalgt()
greater thanlt()
less thangte()
greater or equal thanlte()
less or equal thanmodl(i: i64)
modi
isregx()
matches regex
Mutate
df.col_mut.unwrap.iter_mut.for_each;
Sort
// sort by, sort dir [asc() | desc()]
df.sort.unwrap;
Iterate
let unames = df
.iter
.map
.;
Store
To csv
df.to_csv.unwrap;
Examples
For more examples, see ./tests/integration_test.rs