Dataframe commands (#542)

* groupby object

* aggregate command

* eager commands

* rest of dataframe commands
This commit is contained in:
Fernando Herrera
2021-12-21 18:32:09 +00:00
committed by GitHub
parent c3a16902fe
commit 6a35e6b7b6
44 changed files with 2936 additions and 130 deletions

View File

@ -1,5 +1,5 @@
use super::NuDataFrame;
use nu_protocol::{ast::Operator, Category, CustomValue, ShellError, Span, Value};
use nu_protocol::{ast::Operator, CustomValue, ShellError, Span, Value};
// CustomValue implementation for NuDataFrame
impl CustomValue for NuDataFrame {
@ -20,10 +20,6 @@ impl CustomValue for NuDataFrame {
}
}
fn category(&self) -> Category {
Category::Custom(self.typetag_name().into())
}
fn value_string(&self) -> String {
self.typetag_name().to_string()
}

View File

@ -12,6 +12,8 @@ use polars::prelude::{DataFrame, DataType, PolarsObject, Series};
use serde::{Deserialize, Serialize};
use std::{cmp::Ordering, fmt::Display, hash::Hasher};
use super::utils::DEFAULT_ROWS;
// DataFrameValue is an encapsulation of Nushell Value that can be used
// to define the PolarsObject Trait. The polars object trait allows to
// create dataframes with mixed datatypes
@ -283,7 +285,7 @@ impl NuDataFrame {
pub fn tail(&self, rows: Option<usize>, span: Span) -> Result<Vec<Value>, ShellError> {
let df = &self.0;
let to_row = df.height();
let size = rows.unwrap_or(5);
let size = rows.unwrap_or(DEFAULT_ROWS);
let from_row = to_row.saturating_sub(size);
let values = self.to_rows(from_row, to_row, span)?;