Python's pandas implemented for fast, type safe programming in Rust.
-
CSV
returns CSV struct reading file from given path
let mut content = String::new(); let csv : CSV = dataframe::df::read_csv("test.csv", &mut content); // CSV { headers, values, matrix }
returns DataFrame from a CSV struct
let mut df = csv.get_df(); // DataFrame { columns, dataset, values }
-
DataFrame
returns array of strings, containing column names
df.columns; // ["name","age"]
returns dataset matrix
df.dataset; // [["bob","30"] ["richard", "25"]]
returns vector of pairs, containing column name, and all column values
df.values; // [("name", ["bob", "richard"]), ("age", ["30", "25])]
returns max from all values inside a column
df.max("age"); // 30 as f64
return min from all values inside a column
df.min("age"); // 25 as f64
return mean from all values inside a column
df.mean("age"); // 27.5 as f64
returns sum of all non N/A values from column
df.sum("age"); // 55 as f64
string index for DataFrame, returns all values from a given column
df["age"]; // ["30", "25"]
usize index for DataFrame, returns given row with all columns
df[0]; // ["bob", "30"]
returns sliced dataset matrix from given range
df.iloc([0..2, 0..1].to_vec()); // [["richard"], ["bob"]]
returns if given column on DataFrame has a missing value
df.is_na_col("age"); // false
returns matrix containing missing value bool for each value
df.is_na(); // [[false, false], [false, false]]
returns matrix containing missing value bool for each value
df.push(["ann", "20"]); df.dataset; // [["richard", "30"], ["bob", "25"], ["ann", "20"]]
returns matrix containing missing value bool for each value
df.pop(); // ["ann", "20"] df.pop(); // ["bob", "25"] df.dataset; // [["richard", "30"]]
returns matrix containing missing value bool for each value
df.n_uniques("age"); // 2 as usize
returns matrix containing missing value bool for each value
df.uniques("age"); // ["30", "25"]
applies closure function to each value on given column
fn in_my_twenties<'r>(age: &str) -> &'r str { "20" } df.apply("age", in_my_twenties); df.dataset; // [["richard", "20"], ["bob", "20"]]
assigns given value to each N/A value on column
df.fillna("age", df.mean("age")); // [["richard", "26"], ["bob", "26"]] given bob had no prior age
returns type of each column
df.dtypes // {"age": "numeric", "name": "str" }