All is a DataFrame (#3812)

* nuframe in its own type in UntaggedValue

* Removed eager dataframe from enum

* Dataframe created from list of values

* Corrected order in dataframe columns

* Returned tag from stream collection

* Removed series from dataframe commands

* Arithmetic operators

* forced push

* forced push

* Replace all command

* String commands

* appending operations with dfs

* Testing suite for dataframes

* Unit test for dataframe commands

* improved equality for dataframes
This commit is contained in:
Fernando Herrera
2021-07-25 11:01:54 +01:00
committed by GitHub
parent 9120a64cfb
commit f1ee9113ac
83 changed files with 3293 additions and 1422 deletions

View File

@ -12,7 +12,7 @@ use nu_source::{
use num_traits::cast::ToPrimitive;
#[cfg(feature = "dataframe")]
use nu_protocol::dataframe::{NuSeries, PolarsData};
use nu_protocol::dataframe::NuDataFrame;
pub trait ValueExt {
fn into_parts(self) -> (UntaggedValue, Tag);
@ -203,14 +203,14 @@ pub fn get_data_by_member(value: &Value, name: &PathMember) -> Result<Value, She
}
}
#[cfg(feature = "dataframe")]
UntaggedValue::DataFrame(PolarsData::EagerDataFrame(df)) => match &name.unspanned {
UntaggedValue::DataFrame(df) => match &name.unspanned {
UnspannedPathMember::String(string) => {
let column = df.as_ref().column(string.as_ref()).map_err(|e| {
let column = df.as_ref().select(string.as_str()).map_err(|e| {
ShellError::labeled_error("Dataframe error", format!("{}", e), &name.span)
})?;
Ok(NuSeries::series_to_value(
column.clone(),
Ok(NuDataFrame::dataframe_to_value(
column,
Tag::new(value.anchor(), name.span),
))
}
@ -746,7 +746,7 @@ pub fn get_data<'value>(value: &'value Value, desc: &str) -> MaybeOwned<'value,
MaybeOwned::Owned(UntaggedValue::nothing().into_untagged_value())
}
#[cfg(feature = "dataframe")]
UntaggedValue::DataFrame(_) => {
UntaggedValue::DataFrame(_) | UntaggedValue::FrameStruct(_) => {
MaybeOwned::Owned(UntaggedValue::nothing().into_untagged_value())
}
}