pub struct DataFrame {
    pub data: Vec<Series>,
    pub ics: Vec<String>,
}
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

Declare new DataFrame with Vec<Series>

Change header

Push new pair of head, Series to DataFrame

Extract specific row as DataFrame

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.