Skip to main content

DataOperations

Struct DataOperations 

Source
pub struct DataOperations;
Expand description

Data operations for spreadsheet manipulation

Implementations§

Source§

impl DataOperations

Source

pub fn new() -> Self

Source§

impl DataOperations

Source

pub fn sort_by_column( &self, data: &mut Vec<Vec<String>>, column: usize, order: SortOrder, ) -> Result<()>

Sort rows by a specific column (public for backward compatibility)

Source§

impl DataOperations

Source

pub fn filter_rows( &self, data: &[Vec<String>], column: usize, operator: &str, value: &str, ) -> Result<Vec<Vec<String>>>

Filter rows by a condition on a column (legacy method for compatibility)

Source

pub fn evaluate_filter_condition( &self, cell_value: &str, operator: &str, value: &str, ) -> Result<bool>

Evaluate a filter condition (legacy method for compatibility)

Source

pub fn replace( &self, data: &mut Vec<Vec<String>>, column: usize, find: &str, replace_with: &str, ) -> usize

Replace values in a column

Source

pub fn find_replace( &self, data: &mut Vec<Vec<String>>, find: &str, replace_with: &str, _column: Option<usize>, ) -> Result<usize>

Find and replace across all columns

Source

pub fn deduplicate(&self, data: &[Vec<String>]) -> Vec<Vec<String>>

Remove duplicate rows (returns new vec)

Source

pub fn deduplicate_mut(&self, data: &mut Vec<Vec<String>>) -> usize

Remove duplicate rows in place

Source

pub fn transpose(&self, data: &[Vec<String>]) -> Vec<Vec<String>>

Transpose data (rows to columns)

Source

pub fn to_markdown(&self, data: &[Vec<String>]) -> String

Format data as markdown table

Source

pub fn insert_row( &self, data: &mut Vec<Vec<String>>, index: usize, row: Vec<String>, )

Insert a row at a specific index

Source

pub fn delete_row( &self, data: &mut Vec<Vec<String>>, index: usize, ) -> Option<Vec<String>>

Delete a row at a specific index

Source

pub fn insert_column( &self, data: &mut Vec<Vec<String>>, index: usize, values: Vec<String>, )

Insert a column at a specific index

Source

pub fn delete_column(&self, data: &mut Vec<Vec<String>>, index: usize)

Delete a column at a specific index

Source§

impl DataOperations

Source

pub fn select_columns( &self, data: &[Vec<String>], columns: &[usize], ) -> Vec<Vec<String>>

Select specific columns by index

Source

pub fn select_columns_by_name( &self, data: &[Vec<String>], names: &[&str], ) -> Result<Vec<Vec<String>>>

Select columns by name (first row is header)

Source

pub fn head(&self, data: &[Vec<String>], n: usize) -> Vec<Vec<String>>

Get first n rows (head)

Source

pub fn tail(&self, data: &[Vec<String>], n: usize) -> Vec<Vec<String>>

Get last n rows (tail)

Source

pub fn sample( &self, data: &[Vec<String>], n: usize, seed: Option<u64>, ) -> Vec<Vec<String>>

Sample random rows

Source

pub fn drop_columns( &self, data: &[Vec<String>], columns: &[usize], ) -> Vec<Vec<String>>

Drop columns by index

Source

pub fn rename_columns( &self, data: &mut Vec<Vec<String>>, renames: &[(&str, &str)], ) -> Result<()>

Rename columns (first row is header)

Source

pub fn fillna(&self, data: &mut Vec<Vec<String>>, value: &str)

Fill missing/empty values

Source

pub fn dropna(&self, data: &[Vec<String>]) -> Vec<Vec<String>>

Drop rows with any empty values

Source

pub fn concat(&self, datasets: &[Vec<Vec<String>>]) -> Vec<Vec<String>>

Concatenate multiple datasets vertically

Source

pub fn join( &self, left: &[Vec<String>], right: &[Vec<String>], left_col: usize, right_col: usize, how: JoinType, ) -> Result<Vec<Vec<String>>>

Join two datasets on a column

Source

pub fn groupby( &self, data: &[Vec<String>], group_col: usize, aggregations: &[(usize, AggFunc)], ) -> Result<Vec<Vec<String>>>

Group by column with aggregations

Source

pub fn melt( &self, data: &[Vec<String>], id_vars: &[usize], value_vars: &[usize], ) -> Result<Vec<Vec<String>>>

Unpivot wide → long: repeat id_vars for each value_vars column; add variable and value.

If value_vars is empty, uses every column index not listed in id_vars.

Source§

impl DataOperations

Source

pub fn describe(&self, data: &[Vec<String>]) -> Result<Vec<Vec<String>>>

Describe/summary statistics for all numeric columns

Source

pub fn value_counts( &self, data: &[Vec<String>], column: usize, ) -> Vec<Vec<String>>

Count unique values in a column

Source

pub fn pivot( &self, data: &[Vec<String>], index_col: usize, columns_col: usize, values_col: usize, agg: AggFunc, ) -> Result<Vec<Vec<String>>>

Pivot table

Source

pub fn crosstab( &self, data: &[Vec<String>], row_col: usize, col_col: usize, ) -> Result<Vec<Vec<String>>>

Frequency crosstab: counts of (row_col, col_col) pairs (two categorical columns).

First row is the header: row dimension name, then distinct values from col_col. First column lists distinct values from row_col; cell (r, c) is the count.

Source

pub fn correlation( &self, data: &[Vec<String>], columns: &[usize], ) -> Result<Vec<Vec<String>>>

Correlation matrix

Source

pub fn dtypes(&self, data: &[Vec<String>]) -> Vec<Vec<String>>

Infer column types

Source

pub fn unique(&self, data: &[Vec<String>], column: usize) -> Vec<Vec<String>>

Get unique values in a column

Source

pub fn nunique(&self, data: &[Vec<String>], column: usize) -> usize

Count unique values in a column

Source

pub fn info(&self, data: &[Vec<String>]) -> Vec<Vec<String>>

Get info about the dataset

Source§

impl DataOperations

Source

pub fn query( &self, data: &[Vec<String>], where_clause: &str, ) -> Result<Vec<Vec<String>>>

Query with SQL-like WHERE clause

Source

pub fn mutate( &self, data: &mut Vec<Vec<String>>, new_col_name: &str, formula: &str, ) -> Result<()>

Add computed column using formula

Source

pub fn astype( &self, data: &mut Vec<Vec<String>>, column: usize, dtype: &str, ) -> Result<usize>

Cast column to specified type

Source

pub fn sort_by_columns( &self, data: &mut Vec<Vec<String>>, columns: &[(usize, SortOrder)], ) -> Result<()>

Sort by multiple columns

Source

pub fn apply_column<F>( &self, data: &mut Vec<Vec<String>>, column: usize, f: F, ) -> Result<()>
where F: Fn(&str) -> String,

Apply a function to each cell in a column

Source

pub fn clip( &self, data: &mut Vec<Vec<String>>, column: usize, min: Option<f64>, max: Option<f64>, ) -> Result<usize>

Clip values to a range

Source

pub fn normalize( &self, data: &mut Vec<Vec<String>>, column: usize, ) -> Result<()>

Normalize column values (0-1 range)

Source

pub fn zscore(&self, data: &mut Vec<Vec<String>>, column: usize) -> Result<()>

Standardize numeric column to z-scores using population mean and standard deviation.

Non-numeric cells are left unchanged. If the column has fewer than two numeric values or the standard deviation is zero, cells are unchanged.

Source

pub fn rolling_mean_column( &self, data: &mut Vec<Vec<String>>, value_col: usize, window: usize, new_col_name: &str, ) -> Result<()>

Append a column with rolling mean of value_col over the last window data rows (inclusive). Header is row 0; partial windows at the start use available rows (min_periods = 1).

Source

pub fn rolling_sum_column( &self, data: &mut Vec<Vec<String>>, value_col: usize, window: usize, new_col_name: &str, ) -> Result<()>

Append a column with rolling sum of value_col over the last window data rows (inclusive).

Source

pub fn parse_date( &self, data: &mut Vec<Vec<String>>, column: usize, from_format: &str, to_format: &str, ) -> Result<usize>

Parse and reformat date column

Source

pub fn regex_filter( &self, data: &[Vec<String>], column: usize, pattern: &str, ) -> Result<Vec<Vec<String>>>

Filter rows by regex pattern

Source

pub fn regex_replace( &self, data: &mut Vec<Vec<String>>, column: usize, pattern: &str, replacement: &str, ) -> Result<usize>

Replace values using regex pattern

Source

pub fn extract_date_part( &self, data: &mut Vec<Vec<String>>, column: usize, part: &str, new_col_name: &str, date_format: &str, ) -> Result<()>

Extract date parts (year, month, day, weekday)

Trait Implementations§

Source§

impl FilterOperator for DataOperations

Source§

fn filter( &self, data: &[Vec<String>], column: usize, condition: FilterCondition, ) -> Result<Vec<Vec<String>>>

Source§

impl SortOperator for DataOperations

Source§

fn sort( &self, data: &mut Vec<Vec<String>>, column: usize, ascending: bool, ) -> Result<()>

Source§

impl TransformOperator for DataOperations

Source§

fn transform( &self, data: &mut Vec<Vec<String>>, operation: TransformOperation, ) -> Result<()>

Source§

impl DataOperator for DataOperations

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,