OptimizedDataFrame

Struct OptimizedDataFrame 

Source
pub struct OptimizedDataFrame { /* private fields */ }
Expand description

Optimized DataFrame implementation Uses columnar storage for high-speed data processing

Implementations§

Source§

impl OptimizedDataFrame

Source

pub fn new() -> Self

Create a new empty DataFrame

Source

pub fn row_count(&self) -> usize

Get the number of rows in the DataFrame

Source

pub fn column_count(&self) -> usize

Get the number of columns in the DataFrame

Source

pub fn is_empty(&self) -> bool

Check if the DataFrame is empty

Source

pub fn column_names(&self) -> &[String]

Get the column names

Source

pub fn contains_column(&self, name: &str) -> bool

Check if a column exists

Source§

impl OptimizedDataFrame

Source

pub fn from_csv<P: AsRef<Path>>(path: P, has_header: bool) -> Result<Self>

Create a DataFrame from a CSV file (high-performance implementation)

§Arguments
  • path - Path to the CSV file
  • has_header - Whether the file has a header
§Returns
  • Result<Self> - DataFrame on success, error on failure
Source

pub fn to_csv<P: AsRef<Path>>(&self, path: P, write_header: bool) -> Result<()>

Save DataFrame to a CSV file

§Arguments
  • path - Path to save the file
  • write_header - Whether to write the header
§Returns
  • Result<()> - Ok on success, error on failure
Source

pub fn from_json<P: AsRef<Path>>(path: P) -> Result<Self>

Read DataFrame from a JSON file

§Arguments
  • path - Path to the JSON file
§Returns
  • Result<Self> - DataFrame read from the file
Source

pub fn to_json<P: AsRef<Path>>(&self, path: P, orient: JsonOrient) -> Result<()>

Write DataFrame to a JSON file

§Arguments
  • path - Path to the JSON file
  • orient - JSON output format (Records or Columns)
§Returns
  • Result<()> - Ok on success
Source

pub fn from_dataframe(df: &DataFrame) -> Result<Self>

Create a DataFrame from standard DataFrame (alias for from_standard_dataframe)

This is a public alias provided for backward compatibility with existing code

Source§

impl OptimizedDataFrame

Source

pub fn add_column<C: Into<Column>>( &mut self, name: impl Into<String>, column: C, ) -> Result<()>

Add a column

Source

pub fn add_int_column( &mut self, name: impl Into<String>, data: Vec<i64>, ) -> Result<()>

Add an integer column

Source

pub fn add_float_column( &mut self, name: impl Into<String>, data: Vec<f64>, ) -> Result<()>

Add a floating-point column

Source

pub fn add_string_column( &mut self, name: impl Into<String>, data: Vec<String>, ) -> Result<()>

Add a string column

Source

pub fn add_boolean_column( &mut self, name: impl Into<String>, data: Vec<bool>, ) -> Result<()>

Add a boolean column

Source

pub fn column(&self, name: &str) -> Result<ColumnView>

Get a reference to a column

Source

pub fn column_type(&self, name: &str) -> Result<ColumnType>

Get the type of a column

Source

pub fn remove_column(&mut self, name: &str) -> Result<Column>

Remove a column

Source

pub fn rename_column( &mut self, old_name: &str, new_name: impl Into<String>, ) -> Result<()>

Rename a column

Source

pub fn rename_columns( &mut self, column_map: &HashMap<String, String>, ) -> Result<()>

Rename columns in the DataFrame using a mapping

Source

pub fn set_column_names(&mut self, names: Vec<String>) -> Result<()>

Set all column names in the DataFrame

Source

pub fn get_value( &self, row_idx: usize, column_name: &str, ) -> Result<Option<String>>

Get the value at the specified row and column

Source

pub fn get_index(&self) -> Option<&DataFrameIndex<String>>

Get the index

Source

pub fn set_default_index(&mut self) -> Result<()>

Set the default index

Source

pub fn set_index_directly( &mut self, index: DataFrameIndex<String>, ) -> Result<()>

Set the index directly

Source

pub fn set_index_from_simple_index( &mut self, index: Index<String>, ) -> Result<()>

Set a simple index

Source

pub fn reset_index(&mut self, name: &str, drop_index: bool) -> Result<()>

Add index as a column

Source

pub fn set_index(&mut self, name: &str) -> Result<()>

Set column values as index

Source

pub fn set_index_from_simple_index_internal( &mut self, index: Index<String>, ) -> Result<()>

👎Deprecated: This is an internal method that should not be used directly. Use set_index_from_simple_index instead.

Internal method to set string index directly (for conversion)

§Arguments
  • index - The index to set
§Returns
  • Result<()> - Ok on success, error on failure
Source

pub fn select(&self, columns: &[&str]) -> Result<Self>

Select columns (as a new DataFrame)

Source

pub fn get_string_column(&self, name: &str) -> Result<Vec<String>>

Get string column data

§Arguments
  • name - Column name
§Returns
  • Result<Vec<String>> - String data
Source

pub fn get_float_column(&self, name: &str) -> Result<Vec<f64>>

Get float column data

§Arguments
  • name - Column name
§Returns
  • Result<Vec<f64>> - Float data
Source

pub fn get_int_column(&self, name: &str) -> Result<Vec<Option<i64>>>

Get integer column data

§Arguments
  • name - Column name
§Returns
  • Result<Vec<Option<i64>>> - Integer data with nulls
Source

pub fn len(&self) -> usize

Get the number of rows (alias for row_count)

Source§

impl OptimizedDataFrame

Source

pub fn append(&self, other: &OptimizedDataFrame) -> Result<Self>

Append another DataFrame vertically Concatenate two DataFrames with compatible columns and create a new DataFrame

Source

pub fn head(&self, n: usize) -> Result<Self>

Get the first n rows

Source

pub fn tail(&self, n: usize) -> Result<Self>

Get the last n rows

Source

pub fn sample(&self, n: usize, replace: bool, seed: Option<u64>) -> Result<Self>

Sample rows

Source

pub fn get_row(&self, row_idx: usize) -> Result<Self>

Get a row using integer index (as a new DataFrame)

Source

pub fn get_row_by_index(&self, key: &str) -> Result<Self>

Get a row by index

Source

pub fn select_by_index<I, S>(&self, keys: I) -> Result<Self>
where I: IntoIterator<Item = S>, S: AsRef<str>,

Select rows using index

Source

pub fn filter(&self, condition_column: &str) -> Result<Self>

Filter (as a new DataFrame)

Source

pub fn par_apply<F>(&self, func: F) -> Result<Self>
where F: Fn(&ColumnView) -> Result<Column> + Sync + Send,

Apply mapping function (with parallel processing support)

Source

pub fn par_filter(&self, condition_column: &str) -> Result<Self>

Execute row filtering (automatically selects serial/parallel processing based on data size)

Source

pub fn par_groupby( &self, group_by_columns: &[&str], ) -> Result<HashMap<String, Self>>

Execute groupby operation in parallel (optimized for data size)

Source

pub fn inner_join( &self, other: &Self, left_on: &str, right_on: &str, ) -> Result<Self>

Inner join

Source

pub fn left_join( &self, other: &Self, left_on: &str, right_on: &str, ) -> Result<Self>

Left join

Source

pub fn right_join( &self, other: &Self, left_on: &str, right_on: &str, ) -> Result<Self>

Right join

Source

pub fn outer_join( &self, other: &Self, left_on: &str, right_on: &str, ) -> Result<Self>

Outer join

Source

pub fn apply<F>(&self, f: F, columns: Option<&[&str]>) -> Result<Self>
where F: Fn(&ColumnView) -> Result<Column> + Send + Sync,

Apply function to columns and return a new DataFrame with results (performance optimized version)

§Arguments
  • f - Function to apply (takes column view, returns new column)
  • columns - Target column names (None means all columns)
§Returns
  • Result<Self> - DataFrame with processing results
Source

pub fn applymap<F, G, H, I>( &self, column_name: &str, f_str: F, f_int: G, f_float: H, f_bool: I, ) -> Result<Self>
where F: Fn(&str) -> String + Send + Sync, G: Fn(&i64) -> i64 + Send + Sync, H: Fn(&f64) -> f64 + Send + Sync, I: Fn(&bool) -> bool + Send + Sync,

Apply function to each element (equivalent to applymap)

§Arguments
  • column_name - Target column name
  • f - Function to apply (specific to column type)
§Returns
  • Result<Self> - DataFrame with processing results
Source

pub fn melt( &self, id_vars: &[&str], value_vars: Option<&[&str]>, var_name: Option<&str>, value_name: Option<&str>, ) -> Result<Self>

Convert DataFrame to “long format” (melt operation)

Converts multiple columns into a single “variable” column and “value” column. This implementation prioritizes performance.

§Arguments
  • id_vars - Column names to keep unchanged (identifier columns)
  • value_vars - Column names to convert (value columns). If not specified, all columns except id_vars
  • var_name - Name for the variable column (default: “variable”)
  • value_name - Name for the value column (default: “value”)
§Returns
  • Result<Self> - DataFrame converted to long format
Source

pub fn sum(&self, column_name: &str) -> Result<f64>

Calculate the sum of a numeric column

Source

pub fn mean(&self, column_name: &str) -> Result<f64>

Calculate the mean of a numeric column

Source

pub fn max(&self, column_name: &str) -> Result<f64>

Calculate the maximum value of a numeric column

Source

pub fn min(&self, column_name: &str) -> Result<f64>

Calculate the minimum value of a numeric column

Source

pub fn count(&self, column_name: &str) -> Result<usize>

Count the number of elements in a column (excluding missing values)

Source

pub fn aggregate( &self, column_names: &[&str], operation: &str, ) -> Result<HashMap<String, f64>>

Apply aggregation operation to multiple columns

Source

pub fn sort_by(&self, by: &str, ascending: bool) -> Result<Self>

Sort DataFrame by the specified column

Source

pub fn sort_by_columns( &self, by: &[&str], ascending: Option<&[bool]>, ) -> Result<Self>

Sort DataFrame by multiple columns

Source

pub fn aggregate_numeric(&self, operation: &str) -> Result<HashMap<String, f64>>

Apply aggregation operation to all numeric columns

Source

pub fn concat_rows(&self, other: &Self) -> Result<Self>

Concatenate rows from another DataFrame

This method adds the rows from another DataFrame to this one Both DataFrames must have the same column structure

Source

pub fn sample_rows(&self, indices: &[usize]) -> Result<Self>

Sample rows by index

§Arguments
  • indices - Vector of row indices to include in the new DataFrame
§Returns

A new DataFrame containing only the selected rows

Source§

impl OptimizedDataFrame

Direct aggregation methods for OptimizedDataFrame that eliminate conversion overhead

Source

pub fn sum_direct(&self, column_name: &str) -> Result<f64>

Calculate the sum of a numeric column using direct operations

This method is 3-5x faster than the conversion-based approach by:

  • Working directly on the target column
  • Using optimized column methods with null handling
  • Avoiding full DataFrame copying
Source

pub fn mean_direct(&self, column_name: &str) -> Result<f64>

Calculate the mean of a numeric column using direct operations

Source

pub fn max_direct(&self, column_name: &str) -> Result<f64>

Calculate the maximum value of a numeric column using direct operations

Source

pub fn min_direct(&self, column_name: &str) -> Result<f64>

Calculate the minimum value of a numeric column using direct operations

Source

pub fn count_direct(&self, column_name: &str) -> Result<usize>

Count the number of non-null elements in a column using direct access

Source

pub fn sum_simd(&self, column_name: &str) -> Result<f64>

Calculate the sum of a numeric column using SIMD-accelerated direct operations

This method provides the best performance by combining:

  • Direct column access (3-5x improvement over conversion)
  • SIMD vectorization (2-4x additional improvement)
  • Intelligent fallback for columns with null values
Source

pub fn mean_simd(&self, column_name: &str) -> Result<f64>

Calculate the mean of a numeric column using SIMD-accelerated direct operations

Source

pub fn max_simd(&self, column_name: &str) -> Result<f64>

Calculate the maximum value of a numeric column using SIMD-accelerated direct operations

Source

pub fn min_simd(&self, column_name: &str) -> Result<f64>

Calculate the minimum value of a numeric column using SIMD-accelerated direct operations

Trait Implementations§

Source§

impl Clone for OptimizedDataFrame

Source§

fn clone(&self) -> OptimizedDataFrame

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DataFramePlotExt for OptimizedDataFrame

Source§

fn plot_column<P: AsRef<Path>>( &self, _column: &str, _path: P, _title: Option<&str>, ) -> Result<()>

Plot a column from this DataFrame with minimal configuration
Source§

fn line_plot<P: AsRef<Path>>( &self, _column: &str, _path: P, _title: Option<&str>, ) -> Result<()>

Create a line plot for a column
Source§

fn scatter_plot<P: AsRef<Path>>( &self, _column: &str, _path: P, _title: Option<&str>, ) -> Result<()>

Create a scatter plot for a column
Source§

fn bar_plot<P: AsRef<Path>>( &self, _column: &str, _path: P, _title: Option<&str>, ) -> Result<()>

Create a bar plot for a column
Source§

fn area_plot<P: AsRef<Path>>( &self, _column: &str, _path: P, _title: Option<&str>, ) -> Result<()>

Create an area plot for a column
Source§

fn box_plot<P: AsRef<Path>>( &self, _value_column: &str, _category_column: &str, _path: P, _title: Option<&str>, ) -> Result<()>

Create a box plot for a column grouped by a category
Source§

fn scatter_xy<P: AsRef<Path>>( &self, _x_column: &str, _y_column: &str, _path: P, _title: Option<&str>, ) -> Result<()>

Create a scatter plot between two columns
Source§

fn multi_line_plot<P: AsRef<Path>>( &self, _columns: &[&str], _path: P, _title: Option<&str>, ) -> Result<()>

Create a line plot for multiple columns
Source§

fn plot_svg<P: AsRef<Path>>( &self, _column: &str, _path: P, _plot_kind: PlotKind, _title: Option<&str>, ) -> Result<()>

Save the plot as SVG format
Source§

impl Debug for OptimizedDataFrame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OptimizedDataFrame

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T