Expand description
Generic DataFrame
structure
Example
extern crate peroxide;
use peroxide::fuga::*;
fn main() {
// 1. Series to DataFrame
// 1-1. Declare Series
let a = Series::new(vec![1, 2, 3, 4]);
let b = Series::new(vec![true, false, false, true]);
let c = Series::new(vec![0.1, 0.2, 0.3, 0.4]);
// 1-2. Declare DataFrame (default header: 0, 1, 2)
let mut df = DataFrame::new(vec![a, b, c]);
df.set_header(vec!["a", "b", "c"]);
df.print(); // Pretty print for DataFrame
// 2. Empty DataFrame
let mut dg = DataFrame::new(vec![]);
dg.push("a", Series::new(vec![1,2,3,4]));
dg.push("b", Series::new(vec![true, false, false, true]));
dg.push("c", Series::new(vec![0.1, 0.2, 0.3, 0.4]));
dg.print();
assert_eq!(df, dg);
}
Fields
data: Vec<Series>
ics: Vec<String>
Implementations
Change header
Type casting for DataFrame
Examples
extern crate peroxide;
use peroxide::fuga::*;
fn main() {
let a = Series::new(vec![1i32, 2, 3, 4]);
let b = Series::new(vec![true, false, false, true]);
let mut df = DataFrame::new(vec![a, b]); // I32, Bool
df.as_types(vec![USIZE, U8]); // USIZE, U8
let c = Series::new(vec![1usize, 2, 3, 4]);
let d = Series::new(vec![1u8, 0, 0, 1]);
let dg = DataFrame::new(vec![c, d]);
assert_eq!(df, dg);
}
Drop specific column by header
Examples
extern crate peroxide;
use peroxide::fuga::*;
fn main() {
let a = Series::new(vec![1,2,3,4]);
let b = Series::new(vec![5,6,7,8]);
let mut df = DataFrame::new(vec![a.clone(), b]);
df.set_header(vec!["a", "b"]);
let mut dg = DataFrame::new(vec![a]);
dg.set_header(vec!["a"]);
df.drop("b");
assert_eq!(df, dg);
}
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for DataFrame
impl UnwindSafe for DataFrame
Blanket Implementations
Mutably borrows from an owned value. Read more