use std::fmt::Debug;
use crate::core::error::{Error, Result};
use crate::dataframe::base::DataFrame;
use crate::series::base::Series;
#[derive(Debug, Clone)]
pub struct ColumnView<'a> {
values: &'a [String],
name: Option<String>,
read_only: bool,
}
impl<'a> ColumnView<'a> {
pub fn new(values: &'a [String], name: Option<String>, read_only: bool) -> Self {
Self {
values,
name,
read_only,
}
}
pub fn name(&self) -> Option<&str> {
self.name.as_deref()
}
pub fn values(&self) -> &[String] {
self.values
}
pub fn is_read_only(&self) -> bool {
self.read_only
}
}
pub trait ViewExt {
fn get_column_view<'a>(&'a self, column_name: &str) -> Result<ColumnView<'a>>;
fn head(&self, n: usize) -> Result<Self>
where
Self: Sized;
fn tail(&self, n: usize) -> Result<Self>
where
Self: Sized;
}
impl ViewExt for DataFrame {
fn get_column_view<'a>(&'a self, column_name: &str) -> Result<ColumnView<'a>> {
Err(Error::NotImplemented("get_column_view not implemented yet".to_string()))
}
fn head(&self, n: usize) -> Result<Self> {
Ok(DataFrame::new())
}
fn tail(&self, n: usize) -> Result<Self> {
Ok(DataFrame::new())
}
}