pub struct DataFrame { /* private fields */ }Expand description
Column-major tabular data structure.
Stores named columns of typed data. All columns must have the same number of rows. Supports numeric, boolean, categorical, and text column types.
§Example
use u_insight::dataframe::{DataFrame, Column, ValidityBitmap};
let mut df = DataFrame::new();
df.add_column(
"x".to_string(),
Column::numeric(vec![1.0, 2.0, 3.0], ValidityBitmap::all_valid(3)),
).unwrap();
df.add_column(
"label".to_string(),
Column::text(
vec!["a".into(), "b".into(), "c".into()],
ValidityBitmap::all_valid(3),
),
).unwrap();
assert_eq!(df.row_count(), 3);
assert_eq!(df.column_count(), 2);Implementations§
Source§impl DataFrame
impl DataFrame
Sourcepub fn add_column(
&mut self,
name: String,
column: Column,
) -> Result<(), InsightError>
pub fn add_column( &mut self, name: String, column: Column, ) -> Result<(), InsightError>
Adds a named column to the DataFrame.
Returns an error if the column length doesn’t match the existing row count (unless this is the first column).
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Returns the number of columns.
Sourcepub fn column_names(&self) -> &[String]
pub fn column_names(&self) -> &[String]
Returns column names.
Sourcepub fn column(&self, index: usize) -> Option<&Column>
pub fn column(&self, index: usize) -> Option<&Column>
Returns a reference to the column at index.
Sourcepub fn column_by_name(&self, name: &str) -> Option<&Column>
pub fn column_by_name(&self, name: &str) -> Option<&Column>
Returns a reference to the column with the given name.
Sourcepub fn column_index(&self, name: &str) -> Option<usize>
pub fn column_index(&self, name: &str) -> Option<usize>
Returns the index of the column with the given name.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &Column)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &Column)>
Returns an iterator over (name, column) pairs.
Sourcepub fn total_null_count(&self) -> usize
pub fn total_null_count(&self) -> usize
Returns the total number of null values across all columns.
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