pub struct CsvDataFrame {
pub column_names: Vec<String>,
pub columns: Vec<CsvColumnData>,
}Expand description
A DataFrame-like structure with named, typed columns.
Each column carries its inferred type. Construct via
CsvDataFrame::from_csv or CsvDataFrame::from_str.
Fields§
§column_names: Vec<String>Column names, in order.
columns: Vec<CsvColumnData>Typed column data (parallel to column_names).
Implementations§
Source§impl CsvDataFrame
impl CsvDataFrame
Sourcepub fn from_csv(csv: &CsvFile) -> Self
pub fn from_csv(csv: &CsvFile) -> Self
Build a CsvDataFrame from an existing CsvFile with auto type inference.
Sourcepub fn from_str(s: &str) -> Result<Self, String>
pub fn from_str(s: &str) -> Result<Self, String>
Parse a CSV string and build a CsvDataFrame with type inference.
Returns an error message with the problematic line number if parsing fails.
Sourcepub fn from_str_with_delimiter(s: &str, delim: char) -> Result<Self, String>
pub fn from_str_with_delimiter(s: &str, delim: char) -> Result<Self, String>
Parse a delimiter-separated string and build a CsvDataFrame.
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Return the index of a column by name, or None.
Sourcepub fn column(&self, idx: usize) -> Option<&CsvColumnData>
pub fn column(&self, idx: usize) -> Option<&CsvColumnData>
Return a reference to the typed data of a column by index.
Sourcepub fn column_by_name(&self, name: &str) -> Option<&CsvColumnData>
pub fn column_by_name(&self, name: &str) -> Option<&CsvColumnData>
Return a reference to the typed data of a column by name.
Sourcepub fn float_column(&self, name: &str) -> Option<&Vec<f64>>
pub fn float_column(&self, name: &str) -> Option<&Vec<f64>>
Extract a float column by name. Returns None if not found or wrong type.
Sourcepub fn integer_column(&self, name: &str) -> Option<&Vec<i64>>
pub fn integer_column(&self, name: &str) -> Option<&Vec<i64>>
Extract an integer column by name.
Sourcepub fn to_csv_string(&self) -> String
pub fn to_csv_string(&self) -> String
Serialize the DataFrame back to a CSV string (all values as strings).
Trait Implementations§
Source§impl Clone for CsvDataFrame
impl Clone for CsvDataFrame
Source§fn clone(&self) -> CsvDataFrame
fn clone(&self) -> CsvDataFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CsvDataFrame
impl RefUnwindSafe for CsvDataFrame
impl Send for CsvDataFrame
impl Sync for CsvDataFrame
impl Unpin for CsvDataFrame
impl UnsafeUnpin for CsvDataFrame
impl UnwindSafe for CsvDataFrame
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.