pub struct DataOperations;Expand description
Data operations for spreadsheet manipulation
Implementations§
Source§impl DataOperations
impl DataOperations
Sourcepub fn filter_rows(
&self,
data: &[Vec<String>],
column: usize,
operator: &str,
value: &str,
) -> Result<Vec<Vec<String>>>
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)
Sourcepub fn evaluate_filter_condition(
&self,
cell_value: &str,
operator: &str,
value: &str,
) -> Result<bool>
pub fn evaluate_filter_condition( &self, cell_value: &str, operator: &str, value: &str, ) -> Result<bool>
Evaluate a filter condition (legacy method for compatibility)
Sourcepub fn replace(
&self,
data: &mut Vec<Vec<String>>,
column: usize,
find: &str,
replace_with: &str,
) -> usize
pub fn replace( &self, data: &mut Vec<Vec<String>>, column: usize, find: &str, replace_with: &str, ) -> usize
Replace values in a column
Sourcepub fn find_replace(
&self,
data: &mut Vec<Vec<String>>,
find: &str,
replace_with: &str,
_column: Option<usize>,
) -> Result<usize>
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
Sourcepub fn deduplicate(&self, data: &[Vec<String>]) -> Vec<Vec<String>>
pub fn deduplicate(&self, data: &[Vec<String>]) -> Vec<Vec<String>>
Remove duplicate rows (returns new vec)
Sourcepub fn deduplicate_mut(&self, data: &mut Vec<Vec<String>>) -> usize
pub fn deduplicate_mut(&self, data: &mut Vec<Vec<String>>) -> usize
Remove duplicate rows in place
Sourcepub fn transpose(&self, data: &[Vec<String>]) -> Vec<Vec<String>>
pub fn transpose(&self, data: &[Vec<String>]) -> Vec<Vec<String>>
Transpose data (rows to columns)
Sourcepub fn to_markdown(&self, data: &[Vec<String>]) -> String
pub fn to_markdown(&self, data: &[Vec<String>]) -> String
Format data as markdown table
Sourcepub fn insert_row(
&self,
data: &mut Vec<Vec<String>>,
index: usize,
row: Vec<String>,
)
pub fn insert_row( &self, data: &mut Vec<Vec<String>>, index: usize, row: Vec<String>, )
Insert a row at a specific index
Sourcepub fn delete_row(
&self,
data: &mut Vec<Vec<String>>,
index: usize,
) -> Option<Vec<String>>
pub fn delete_row( &self, data: &mut Vec<Vec<String>>, index: usize, ) -> Option<Vec<String>>
Delete a row at a specific index
Source§impl DataOperations
impl DataOperations
Sourcepub fn select_columns(
&self,
data: &[Vec<String>],
columns: &[usize],
) -> Vec<Vec<String>>
pub fn select_columns( &self, data: &[Vec<String>], columns: &[usize], ) -> Vec<Vec<String>>
Select specific columns by index
Sourcepub fn select_columns_by_name(
&self,
data: &[Vec<String>],
names: &[&str],
) -> Result<Vec<Vec<String>>>
pub fn select_columns_by_name( &self, data: &[Vec<String>], names: &[&str], ) -> Result<Vec<Vec<String>>>
Select columns by name (first row is header)
Sourcepub fn sample(
&self,
data: &[Vec<String>],
n: usize,
seed: Option<u64>,
) -> Vec<Vec<String>>
pub fn sample( &self, data: &[Vec<String>], n: usize, seed: Option<u64>, ) -> Vec<Vec<String>>
Sample random rows
Sourcepub fn drop_columns(
&self,
data: &[Vec<String>],
columns: &[usize],
) -> Vec<Vec<String>>
pub fn drop_columns( &self, data: &[Vec<String>], columns: &[usize], ) -> Vec<Vec<String>>
Drop columns by index
Sourcepub fn rename_columns(
&self,
data: &mut Vec<Vec<String>>,
renames: &[(&str, &str)],
) -> Result<()>
pub fn rename_columns( &self, data: &mut Vec<Vec<String>>, renames: &[(&str, &str)], ) -> Result<()>
Rename columns (first row is header)
Sourcepub fn concat(&self, datasets: &[Vec<Vec<String>>]) -> Vec<Vec<String>>
pub fn concat(&self, datasets: &[Vec<Vec<String>>]) -> Vec<Vec<String>>
Concatenate multiple datasets vertically
Sourcepub fn join(
&self,
left: &[Vec<String>],
right: &[Vec<String>],
left_col: usize,
right_col: usize,
how: JoinType,
) -> Result<Vec<Vec<String>>>
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§impl DataOperations
impl DataOperations
Sourcepub fn describe(&self, data: &[Vec<String>]) -> Result<Vec<Vec<String>>>
pub fn describe(&self, data: &[Vec<String>]) -> Result<Vec<Vec<String>>>
Describe/summary statistics for all numeric columns
Sourcepub fn value_counts(
&self,
data: &[Vec<String>],
column: usize,
) -> Vec<Vec<String>>
pub fn value_counts( &self, data: &[Vec<String>], column: usize, ) -> Vec<Vec<String>>
Count unique values in a column
Sourcepub fn pivot(
&self,
data: &[Vec<String>],
index_col: usize,
columns_col: usize,
values_col: usize,
agg: AggFunc,
) -> Result<Vec<Vec<String>>>
pub fn pivot( &self, data: &[Vec<String>], index_col: usize, columns_col: usize, values_col: usize, agg: AggFunc, ) -> Result<Vec<Vec<String>>>
Pivot table
Sourcepub fn crosstab(
&self,
data: &[Vec<String>],
row_col: usize,
col_col: usize,
) -> Result<Vec<Vec<String>>>
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.
Sourcepub fn correlation(
&self,
data: &[Vec<String>],
columns: &[usize],
) -> Result<Vec<Vec<String>>>
pub fn correlation( &self, data: &[Vec<String>], columns: &[usize], ) -> Result<Vec<Vec<String>>>
Correlation matrix
Sourcepub fn unique(&self, data: &[Vec<String>], column: usize) -> Vec<Vec<String>>
pub fn unique(&self, data: &[Vec<String>], column: usize) -> Vec<Vec<String>>
Get unique values in a column
Source§impl DataOperations
impl DataOperations
Sourcepub fn query(
&self,
data: &[Vec<String>],
where_clause: &str,
) -> Result<Vec<Vec<String>>>
pub fn query( &self, data: &[Vec<String>], where_clause: &str, ) -> Result<Vec<Vec<String>>>
Query with SQL-like WHERE clause
Sourcepub fn mutate(
&self,
data: &mut Vec<Vec<String>>,
new_col_name: &str,
formula: &str,
) -> Result<()>
pub fn mutate( &self, data: &mut Vec<Vec<String>>, new_col_name: &str, formula: &str, ) -> Result<()>
Add computed column using formula
Sourcepub fn astype(
&self,
data: &mut Vec<Vec<String>>,
column: usize,
dtype: &str,
) -> Result<usize>
pub fn astype( &self, data: &mut Vec<Vec<String>>, column: usize, dtype: &str, ) -> Result<usize>
Cast column to specified type
Sourcepub fn sort_by_columns(
&self,
data: &mut Vec<Vec<String>>,
columns: &[(usize, SortOrder)],
) -> Result<()>
pub fn sort_by_columns( &self, data: &mut Vec<Vec<String>>, columns: &[(usize, SortOrder)], ) -> Result<()>
Sort by multiple columns
Sourcepub fn apply_column<F>(
&self,
data: &mut Vec<Vec<String>>,
column: usize,
f: F,
) -> Result<()>
pub fn apply_column<F>( &self, data: &mut Vec<Vec<String>>, column: usize, f: F, ) -> Result<()>
Apply a function to each cell in a column
Sourcepub fn clip(
&self,
data: &mut Vec<Vec<String>>,
column: usize,
min: Option<f64>,
max: Option<f64>,
) -> Result<usize>
pub fn clip( &self, data: &mut Vec<Vec<String>>, column: usize, min: Option<f64>, max: Option<f64>, ) -> Result<usize>
Clip values to a range
Sourcepub fn normalize(
&self,
data: &mut Vec<Vec<String>>,
column: usize,
) -> Result<()>
pub fn normalize( &self, data: &mut Vec<Vec<String>>, column: usize, ) -> Result<()>
Normalize column values (0-1 range)
Sourcepub fn zscore(&self, data: &mut Vec<Vec<String>>, column: usize) -> Result<()>
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.
Sourcepub fn rolling_mean_column(
&self,
data: &mut Vec<Vec<String>>,
value_col: usize,
window: usize,
new_col_name: &str,
) -> Result<()>
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).
Sourcepub fn rolling_sum_column(
&self,
data: &mut Vec<Vec<String>>,
value_col: usize,
window: usize,
new_col_name: &str,
) -> Result<()>
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).
Sourcepub fn parse_date(
&self,
data: &mut Vec<Vec<String>>,
column: usize,
from_format: &str,
to_format: &str,
) -> Result<usize>
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
Sourcepub fn regex_filter(
&self,
data: &[Vec<String>],
column: usize,
pattern: &str,
) -> Result<Vec<Vec<String>>>
pub fn regex_filter( &self, data: &[Vec<String>], column: usize, pattern: &str, ) -> Result<Vec<Vec<String>>>
Filter rows by regex pattern
Trait Implementations§
Source§impl FilterOperator for DataOperations
impl FilterOperator for DataOperations
Source§impl SortOperator for DataOperations
impl SortOperator for DataOperations
Source§impl TransformOperator for DataOperations
impl TransformOperator for DataOperations
impl DataOperator for DataOperations
Auto Trait Implementations§
impl Freeze for DataOperations
impl RefUnwindSafe for DataOperations
impl Send for DataOperations
impl Sync for DataOperations
impl Unpin for DataOperations
impl UnsafeUnpin for DataOperations
impl UnwindSafe for DataOperations
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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