pub struct DataFrame {
pub columns: Vec<(String, Column)>,
}Expand description
A columnar DataFrame.
Fields§
§columns: Vec<(String, Column)>Implementations§
Source§impl DataFrame
impl DataFrame
Sourcepub fn from_columns(columns: Vec<(String, Column)>) -> Result<Self, DataError>
pub fn from_columns(columns: Vec<(String, Column)>) -> Result<Self, DataError>
Create a DataFrame from a list of named columns.
Returns an error if column lengths are not all equal.
Sourcepub fn nrows(&self) -> usize
pub fn nrows(&self) -> usize
Returns the number of rows (determined from the first column, or 0 if empty).
Sourcepub fn column_names(&self) -> Vec<&str>
pub fn column_names(&self) -> Vec<&str>
Returns the column names in order.
Sourcepub fn get_column(&self, name: &str) -> Option<&Column>
pub fn get_column(&self, name: &str) -> Option<&Column>
Look up a column by name, returning a reference if found.
Source§impl DataFrame
impl DataFrame
Sourcepub fn to_tensor(&self, col_names: &[&str]) -> Result<Tensor, DataError>
pub fn to_tensor(&self, col_names: &[&str]) -> Result<Tensor, DataError>
Convert selected numeric columns to a cjc_runtime::Tensor with shape
[nrows, len(col_names)] (row-major).
All selected columns must be Float or Int; Str and Bool columns
will return DataError::InvalidOperation.
Convert selected numeric columns into a Tensor with shape [nrows, ncols].
Sourcepub fn push_row(&mut self, values: &[&str]) -> Result<(), DataError>
pub fn push_row(&mut self, values: &[&str]) -> Result<(), DataError>
Append a single row of string values (parsed to the column type).
values must match self.ncols() in length.
Each string is parsed according to the existing column type:
Float: parsed as f64, falls back to 0.0 on parse errorInt: parsed as i64, falls back to 0 on parse errorStr: stored as-isBool:"true"/"1"→ true, anything else → false
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataFrame
impl RefUnwindSafe for DataFrame
impl Send for DataFrame
impl Sync for DataFrame
impl Unpin for DataFrame
impl UnsafeUnpin for DataFrame
impl UnwindSafe for DataFrame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more