pub struct DataFrame { /* private fields */ }
Expand description
The container for Series<T>
objects, allowing for additional functionality
Implementations§
source§impl DataFrame
impl DataFrame
sourcepub fn len(&self) -> Option<usize>
pub fn len(&self) -> Option<usize>
Length of the dataframe
Example
use blackjack::prelude::*;
let mut df = DataFrame::new();
assert_eq!(df.len(), None);
let series: Series<i32> = Series::arange(0, 10);
df.add_column(series).unwrap();
assert_eq!(df.len(), Some(10));
sourcepub fn add_column<T: BlackJackData>(
&mut self,
series: Series<T>
) -> Result<(), BlackJackError>
pub fn add_column<T: BlackJackData>(
&mut self,
series: Series<T>
) -> Result<(), BlackJackError>
Add a column to this dataframe.
sourcepub fn get_column<'a, T>(
&self,
name: impl Into<&'a str>
) -> Result<Series<T>, BlackJackError>where
T: BlackJackData,
pub fn get_column<'a, T>(
&self,
name: impl Into<&'a str>
) -> Result<Series<T>, BlackJackError>where
T: BlackJackData,
Retrieves a column from the dataframe as an owned representation of it.
sourcepub fn columns(&self) -> impl Iterator<Item = &str>
pub fn columns(&self) -> impl Iterator<Item = &str>
Get a list of column names in this dataframe as an iterator
sourcepub fn read_csv<S>(path: S, delimiter: u8) -> Result<Self, BlackJackError>where
S: AsRef<OsStr> + ToString,
pub fn read_csv<S>(path: S, delimiter: u8) -> Result<Self, BlackJackError>where
S: AsRef<OsStr> + ToString,
Read a CSV file into a DataFrame
where each column represents a Series
supports automatic decompression of gzipped files if they end with .gz
Example
use blackjack::prelude::*;
let path = format!("{}/tests/data/basic_csv.csv", env!("CARGO_MANIFEST_DIR"));
let df = DataFrame::read_csv(&path, b',').unwrap();
let col1: Series<f32> = df.get_column("col1").unwrap();
assert_eq!(col1.sum() as i32, 15);