PURUDA
PUre RUst DAtaframe
Compile-time type-safe DataFrame library for Rust. Provides Col1–Col32 generic structs with zero-cost column access, numeric statistics, filtering, sorting, and CSV/JSON I/O.
Quick Start
Add to your Cargo.toml:
[]
= "0.2"
Example
use *;
API Overview
Column Access & Shape
| Method | Description |
|---|---|
c1() .. cN() |
Immutable reference to column |
c1_mut() .. cN_mut() |
Mutable reference to column |
nrows() |
Number of rows |
ncols() |
Number of columns |
shape() |
(nrows, ncols) tuple |
len() |
Alias for nrows() |
is_empty() |
true if no rows |
Slicing
| Method | Description |
|---|---|
head(n) |
First n rows |
tail(n) |
Last n rows |
slice(start, end) |
Rows in start..end |
Row Operations
| Method | Description |
|---|---|
push_row(v1, .., vN) |
Append a single row |
filter(predicate) |
Keep rows where predicate(row_index) is true |
append(&other) |
In-place vertical concatenation |
concat(other) |
Returns a new concatenated DataFrame |
reindex(&[usize]) |
Rearrange rows by index array |
Sorting
| Method | Description |
|---|---|
sort_by_c1() .. sort_by_cN() |
Sort all rows by column (ascending, requires Ord) |
Column-Level Traits
Numeric (for Vec<i32>, Vec<f64>, etc.)
| Method | Description |
|---|---|
sum() |
Sum of elements |
mean() |
Arithmetic mean (f64) |
min_val() |
Minimum value reference |
max_val() |
Maximum value reference |
var() |
Population variance (f64) |
std_dev() |
Population standard deviation (f64) |
ColumnUnique (for types implementing Eq + Hash)
| Method | Description |
|---|---|
unique() |
Deduplicated values (preserving order) |
n_unique() |
Count of unique values |
ColumnApply
| Method | Description |
|---|---|
apply(f) |
Mutate each element in-place |
ColumnDisplay
| Method | Description |
|---|---|
print() |
Print column as [v1, v2, ...] |
Utility
| Function | Description |
|---|---|
map_column(col, f) |
Map column to a new Vec<U> (type conversion) |
describe() |
Print summary table (name, count per column) |
I/O
| Trait | Methods | Format |
|---|---|---|
CSV |
write_csv(path, delimiter), read_csv(path, delimiter) |
CSV |
JsonIO |
write_json(path), read_json(path), to_json_string(), from_json_string(s) |
JSON |
JSON format:
Supported Column Types
Vec<bool>, Vec<u32>, Vec<u64>, Vec<usize>, Vec<i32>, Vec<i64>, Vec<isize>, Vec<f32>, Vec<f64>, Vec<String>, Vec<&str>
Any type implementing the Column trait can be used as a column.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.