[][src]Struct ravencol::RawFrame

pub struct RawFrame {
    pub records: Vec<StringRecord>,
    pub columns: StringRecord,
}

Main data struct. It contains a vec of StringRecords and the name of the columns from the CSV file.

The normal way of creating a RawFrame is from a CSV file. This file will be parsed with CSV crate functions. The struct has a creator method using os_strings as path for the CSV file and a creator method form terminal arg in position n.

A RawFrame is similir to a DataFrame. It is a tabular data structure. It is possible to operate over columns which are created with methods. All the column extraction methods return iterators, the main objective extracting a column is to operate with it. The intention is ti produce an iterator which is consumed in the column calculation.

In order to computo over columns it is important to decide the type of datum to use in the calculation and if the operation needs full columns or only parsed valid columns for the required type.

Once the type of the column is decided it is necessary to decide what to do with the data which is not possible to parse to this type. Three options are provided. Keep it blank through Option types, impute it with a none_value or filter them out of the column.

Fields

records: Vec<StringRecord>columns: StringRecord

Implementations

impl RawFrame[src]

pub fn from_os_string(file_path: OsString) -> Result<RawFrame, Box<dyn Error>>[src]

Creates a RawFrame from an os_string.

Arguments

  • file_path - An OsString that holds the path of CSV file

Examples

use ravencol::RawFrame;
use std::ffi::OsString;

let path = OsString::from("./datos_test/test.csv");
let datos = RawFrame::from_os_string(path).unwrap();

pub fn from_arg(n: usize) -> Result<RawFrame, Box<dyn Error>>[src]

Creates a RawFrame from terminal argument in position n.

Arguments

  • n - A usize that holds the position of the terminal argument on which is the path of CSV file

pub fn concat(&mut self, cola: RawFrame) -> Result<(), Box<dyn Error>>[src]

pub fn col_index(&self, column: &str) -> Option<usize>[src]

Returns the position index for column in RawFrame or None if column does not exists.

Arguments

  • column - A string slice that holds the name of the column

Examples

use ravencol::RawFrame;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
} 
 
let datos = get_data();
 
assert_eq!(datos.col_index("col_b"),Some(1));

pub fn column(
    &self,
    column: &str
) -> Result<impl Iterator<Item = Datum<'_>> + '_, Box<dyn Error>>
[src]

Returns a full column of Datum. The column is in a consumible iterator. Each element has Datum type. All the valid rows are included. The Datum type mixes several posibilities of types, this generates a general column. For simple operations or plotting use specific type columns.

Arguments

  • column - A string slice that holds the name of the column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
}
 
let datos = get_data();
 
let col: Vec<Datum> = datos.column("col_a").unwrap().collect();

pub fn col_type<T>(
    &self,
    column: &str
) -> Result<impl Iterator<Item = Option<T>> + '_, Box<dyn Error>> where
    T: FromStr
[src]

Returns a full column of a generic type. The column is in a consumible iterator. Each element has Option type. All the valid rows are included. The generic type is specified in the definition of the variable in which the iterator will bind. This method feels repetitive with methods that returns specific type columns because was created after the definition of those. In the future the specific type columns will dissapear.

Arguments

  • column - A string slice that holds the name of the column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
}
 
let datos = get_data();
 
let col: Vec<Option<i32>> = datos.col_type("col_a").unwrap().collect();

pub fn col_fil<T>(
    &self,
    column: &str
) -> Result<impl Iterator<Item = T> + '_, Box<dyn Error>> where
    T: FromStr
[src]

Returns a filtered column of generic type filtering for only the possible to parse data. The column is in a consumible iterator. Each element has T type. Only the valid parsed rows are included. The generic type is specified in the definition of the variable in which the iterator will bind. This method has a variable number of elements related to the rows in the RawDataframe, use it with caution. This method feels repetitive with methods that returns specific type columns because was created after the definition of those. In the future the specific type columns will dissapear.

Arguments

  • column - A string slice that holds the name of the column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
}
 
let datos = get_data();
 
let col: Vec<i32> = datos.col_fil("col_a").unwrap().collect();

pub fn col_imp<T>(
    &self,
    column: &str,
    none_val: T
) -> Result<impl Iterator<Item = T> + '_, Box<dyn Error>> where
    T: FromStr + Clone + 'static, 
[src]

Returns a full column of a generic type imputing none_val in the impossible to parse data. The column is in a consumible iterator. Each element has T type. All the valid rows are included. The generic type is specified in the definition of the variable in which the iterator will bind. This method feels repetitive with methods that returns specific type columns because was created after the definition of those. In the future the specific type columns will dissapear.

Arguments

  • column - A string slice that holds the name of the column

  • none_val - value for imputing the impossible to parse values

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
} 
 
let datos = get_data();
 
let col: Vec<i32> = datos.col_imp("col_a",0).unwrap().collect();

pub fn max_num_fil<T>(&self, column: &str) -> Result<T, Box<dyn Error>> where
    T: FromStr + Ord
[src]

Returns the maximum value of a column. The type is generic for comparable types, in order to compare floats is necessary to define std::cmp::Ord or use ordered-float crate or similar

Arguments

  • column - A string slice that holds the name of the column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
} 
 
let datos = get_data();
 
let maximo: i32 = datos.max_num_fil("col_a").unwrap();

pub fn min_num_fil<T>(&self, column: &str) -> Result<T, Box<dyn Error>> where
    T: FromStr + Ord
[src]

Returns the minimum value of a column. The type is generic for comparable types, in order to compare floats is necessary to define std::cmp::Ord or use ordered-float crate or similar

Arguments

  • column - A string slice that holds the name of the column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
} 
 
let datos = get_data();
 
let minimo: i32 = datos.min_num_fil("col_a").unwrap();

pub fn extent_num_fil<T>(&self, column: &str) -> Result<(T, T), Box<dyn Error>> where
    T: FromStr + Ord
[src]

Returns the extent of range of a column. A tuple with minimum and maximum. The type is generic for comparable types, in order to compare floats is necessary to define std::cmp::Ord or use ordered-float crate or similar

Arguments

  • column - A string slice that holds the name of the column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
} 
 
let datos = get_data();
 
let extent: (i32,i32) = datos.extent_num_fil("col_a").unwrap();

pub fn pair_col_fil<T>(
    &self,
    xcolumn: &str,
    ycolumn: &str
) -> Result<impl Iterator<Item = (T, T)> + '_, Box<dyn Error>> where
    T: FromStr
[src]

Returns a pair of columns of generic type filtering for rows where both values can be parsed. The result is in a consumible iterator. Each element is a tuple of T type. The generic type is specified in the definition of the variable in which the iterator will bind. This method has a variable number of elements related to the rows in the RawDataframe, use it with caution. This method is mainly used for compute operations between two columns and to generate a pair of coordinates to plot.

Arguments

  • xcolumn - A string slice that holds the name of first the column
  • ycolumn - A string slice that holds the name of second the column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
}
 
let datos = get_data();
 
let pairs: Vec<(f64,f64)> = datos.pair_col_fil("col_a","col_b").unwrap().collect();

pub fn pair_col_imp<T>(
    &self,
    xcolumn: &str,
    ycolumn: &str,
    none_val_x: T,
    none_val_y: T
) -> Result<impl Iterator<Item = (T, T)> + '_, Box<dyn Error>> where
    T: FromStr + Clone + 'static, 
[src]

Returns a pair of columns of generic type imputing in the impossible to parse data none_val_x for the first column and none_val_y for the second column. The result is in a consumible iterator. Each element is a tuple of T type. All the valid rows are included. The generic type is specified in the definition of the variable in which the iterator will bind. This method is mainly used for compute operations between two columns and to generate a pair of coordinates to plot.

Arguments

  • xcolumn - A string slice that holds the name of first the column

  • ycolumn - A string slice that holds the name of second the column

  • none_val_x - value for imputing the impossible to parse values for the first column

  • none_val_y - value for imputing the impossible to parse values for the second column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
} 
 
let datos = get_data();
 
let col: Vec<i32> = datos.col_imp("col_a",0).unwrap().collect();

pub fn slice_col_imp<T>(
    &self,
    columns: Vec<&str>,
    imp_vals: Vec<T>
) -> Result<impl Iterator<Item = Vec<T>> + '_, Box<dyn Error>> where
    T: FromStr + Clone + 'static, 
[src]

Returns a slice of columns of generic type imputing in the impossible to parse data the values in the imp_vals Vec. The result is in a consumible iterator. Each element is a vec of T type. All the valid rows are included. The generic type is specified in the definition of the variable in which the iterator will bind. This method is mainly used for compute operations between two columns and to generate a pair of coordinates to plot.

Arguments

  • columns - A Vec of string slices that holds the names of the columns to get

  • imp_vals - values for imputing the impossible to parse values, it has the same order of columns

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
} 
 
let datos = get_data();
 
let col: Vec<Vec<i32>> = datos.slice_col_imp(vec!["col_a","col_b"],vec![0,0]).unwrap().collect();

pub fn slice_col_fil<T>(
    &self,
    columns: Vec<&str>
) -> Result<impl Iterator<Item = Vec<T>> + '_, Box<dyn Error>> where
    T: FromStr + Clone
[src]

Returns a slice of columns of generic type filtering for rows where all values can be parsed. The result is in a consumible iterator. Each element is a vec of T type. The generic type is specified in the definition of the variable in which the iterator will bind. This method has a variable number of elements related to the rows in the RawDataframe, use it with caution.

Arguments

  • columns -A Vec of string slices that holds the names of the columns to get

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
}
 
let datos = get_data();
 
let pairs: Vec<Vec<f64>> = datos.slice_col_fil(vec!["col_a","col_b"]).unwrap().collect();

pub fn pair_col_fil_sorted<T>(
    &self,
    xcolumn: &str,
    ycolumn: &str
) -> Result<impl Iterator<Item = (T, T)> + '_, Box<dyn Error>> where
    T: FromStr + PartialOrd + 'static, 
[src]

Returns a pair of columns of generic type sorted by values on first column. Imputing in the impossible to parse data none_val_x for the first column and none_val_y for the second column. The result is in a consumible iterator. Each element is a tuple of T type. The generic type is specified in the definition of the variable in which the iterator will bind. This method has a variable number of elements related to the rows in the RawDataframe, use it with caution. This method has a different order related to the rows in the RawDataframe, use it with caution. This method is mainly used for compute operations between two columns and to generate a pair of coordinates to plot.

Arguments

  • xcolumn - A string slice that holds the name of first the column
  • ycolumn - A string slice that holds the name of second the column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
}
 
let datos = get_data();
 
let pairs: Vec<(f64,f64)> = datos.pair_col_fil_sorted("col_a","col_b").unwrap().collect();

pub fn pair_col_imp_sorted<T>(
    &self,
    xcolumn: &str,
    ycolumn: &str,
    none_val_x: T,
    none_val_y: T
) -> Result<impl Iterator<Item = (T, T)> + '_, Box<dyn Error>> where
    T: FromStr + PartialOrd + Copy + 'static, 
[src]

Returns a pair of columns of generic type sorted by values on first column. Filtering for rows where both values can be parsed. The result is in a consumible iterator. Each element is a tuple of T type. The generic type is specified in the definition of the variable in which the iterator will bind. This method has a variable number of elements related to the rows in the RawDataframe, use it with caution. This method has a different order related to the rows in the RawDataframe, use it with caution. This method is mainly used for compute operations between two columns and to generate a pair of coordinates to plot.

Arguments

  • xcolumn - A string slice that holds the name of first the column
  • ycolumn - A string slice that holds the name of second the column

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
}
 
let datos = get_data();
 
let pairs: Vec<(f64,f64)> = datos.pair_col_imp_sorted("col_a","col_b",0.0,0.0).unwrap().collect();

pub fn column_major_vector<T>(
    &self,
    columns: Vec<&str>,
    imp_vals: Vec<T>
) -> Result<Vec<T>, Box<dyn Error>> where
    T: FromStr + Copy + 'static, 
[src]

Returns a vec of generic type imputing in the impossible to parse data the values in the imp_vals Vec. The result is a vec of concatenated columns in order to generate a vec which can be used for matrix creation in linear algebra crates like ndarray and nalgebra. The order in the vec is major column

Arguments

  • columns - A Vec of string slices that holds the names of the columns to get

  • imp_vals - values for imputing the impossible to parse values, it has the same order of columns

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
} 
 
let datos = get_data();
 
let mcvec: Vec<f64> = datos.column_major_vector(vec!["col_a","col_b"],vec![0.0,0.0]).unwrap();

pub fn row_major_vector<T>(
    &self,
    columns: Vec<&str>,
    imp_vals: Vec<T>
) -> Result<Vec<T>, Box<dyn Error>> where
    T: FromStr + Copy + 'static, 
[src]

Returns a vec of generic type imputing in the impossible to parse data the values in the imp_vals Vec. The result is a vec of concatenated rows in order to generate a vec which can be used for matrix creation in linear algebra crates like ndarray and nalgebra. The order in the vec is major row

Arguments

  • columns - A Vec of string slices that holds the names of the columns to get

  • imp_vals - values for imputing the impossible to parse values, it has the same order of columns

Examples

use ravencol::RawFrame;
use ravencol::Datum;
use std::ffi::OsString;

fn get_data() -> ravencol::RawFrame {
    let path = OsString::from("./datos_test/test.csv");
    let datos = RawFrame::from_os_string(path).unwrap();
    datos
} 
 
let datos = get_data();
 
let mrvec: Vec<f64> = datos.row_major_vector(vec!["col_a","col_b"],vec![0.0,0.0]).unwrap();

Trait Implementations

impl Debug for RawFrame[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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.

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.