Struct peroxide::structure::dataframe::DataFrame[][src]

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

impl DataFrame[src]

pub fn new(v: Vec<Series>) -> Self[src]

Declare new DataFrame with Vec<Series>

pub fn header(&self) -> &Vec<String>[src]

pub fn header_mut(&mut self) -> &mut Vec<String>[src]

pub fn set_header(&mut self, new_header: Vec<&str>)[src]

Change header

pub fn push(&mut self, name: &str, series: Series)[src]

Push new pair of head, Series to DataFrame

pub fn row(&self, i: usize) -> DataFrame[src]

Extract specific row as DataFrame

pub fn spread(&self) -> String[src]

pub fn as_types(&mut self, dtypes: Vec<DType>)[src]

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);
}

pub fn drop(&mut self, col_header: &str)[src]

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

impl Clone for DataFrame[src]

fn clone(&self) -> DataFrame[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for DataFrame[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Display for DataFrame[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Index<&'_ str> for DataFrame[src]

type Output = Series

The returned type after indexing.

fn index(&self, index: &str) -> &Self::Output[src]

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

impl Index<usize> for DataFrame[src]

type Output = Series

The returned type after indexing.

fn index(&self, index: usize) -> &Self::Output[src]

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

impl IndexMut<&'_ str> for DataFrame[src]

fn index_mut(&mut self, index: &str) -> &mut Self::Output[src]

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

impl IndexMut<usize> for DataFrame[src]

fn index_mut(&mut self, index: usize) -> &mut Self::Output[src]

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

impl PartialEq<DataFrame> for DataFrame[src]

fn eq(&self, other: &DataFrame) -> bool[src]

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

fn ne(&self, other: &DataFrame) -> bool[src]

This method tests for !=.

impl Printable for DataFrame[src]

fn print(&self)[src]

impl StructuralPartialEq for DataFrame[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V