use crate::core::data_value::DataValue;
use crate::core::error::Result;
use std::collections::HashMap;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Axis {
Row = 0,
Column = 1,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DropNaHow {
Any, All, }
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FillMethod {
Forward, Backward, Zero, Mean, Interpolate, }
#[derive(Debug, Clone)]
pub struct DataFrameInfo {
pub shape: (usize, usize),
pub memory_usage: usize,
pub null_counts: HashMap<String, usize>,
pub dtypes: HashMap<String, String>,
}
pub trait DataFrameOps {
type Output: DataFrameOps;
type Error: std::error::Error + Send + Sync + 'static;
fn select(&self, columns: &[&str]) -> Result<Self::Output>;
fn drop(&self, columns: &[&str]) -> Result<Self::Output>;
fn rename(&self, mapping: &HashMap<String, String>) -> Result<Self::Output>;
fn filter<F>(&self, predicate: F) -> Result<Self::Output>
where
F: Fn(&dyn DataValue) -> bool + Send + Sync;
fn head(&self, n: usize) -> Result<Self::Output>;
fn tail(&self, n: usize) -> Result<Self::Output>;
fn sample(&self, n: usize, random_state: Option<u64>) -> Result<Self::Output>;
fn sort_values(&self, by: &[&str], ascending: &[bool]) -> Result<Self::Output>;
fn sort_index(&self) -> Result<Self::Output>;
fn shape(&self) -> (usize, usize);
fn columns(&self) -> Vec<String>;
fn dtypes(&self) -> HashMap<String, String>;
fn info(&self) -> DataFrameInfo;
fn dropna(&self, axis: Option<Axis>, how: DropNaHow) -> Result<Self::Output>;
fn fillna(&self, value: &dyn DataValue, method: Option<FillMethod>) -> Result<Self::Output>;
fn isna(&self) -> Result<Self::Output>;
fn map<F>(&self, func: F) -> Result<Self::Output>
where
F: Fn(&dyn DataValue) -> Box<dyn DataValue> + Send + Sync;
fn apply<F>(&self, func: F, axis: Axis) -> Result<Self::Output>
where
F: Fn(&Self::Output) -> Box<dyn DataValue> + Send + Sync;
}