Series arithmetic (#3602)

* operations with series

* contains operations with series

* Checked division and masked operations
This commit is contained in:
Fernando Herrera
2021-06-10 22:39:51 +01:00
committed by GitHub
parent 1d7c909080
commit c4163c3621
13 changed files with 812 additions and 90 deletions

View File

@ -4,11 +4,29 @@ use nu_protocol::hir::Operator;
use nu_protocol::{Primitive, ShellTypeName, UntaggedValue, Value};
use std::ops::Not;
#[cfg(feature = "dataframe")]
use nu_data::dataframe::{compute_between_series, compute_series_single_value};
#[cfg(feature = "dataframe")]
use nu_protocol::dataframe::PolarsData;
pub fn apply_operator(
op: Operator,
left: &Value,
right: &Value,
) -> Result<UntaggedValue, (&'static str, &'static str)> {
#[cfg(feature = "dataframe")]
if let (
UntaggedValue::DataFrame(PolarsData::Series(_)),
UntaggedValue::DataFrame(PolarsData::Series(_)),
) = (&left.value, &right.value)
{
return compute_between_series(op, left, right);
} else if let (UntaggedValue::DataFrame(PolarsData::Series(_)), UntaggedValue::Primitive(_)) =
(&left.value, &right.value)
{
return compute_series_single_value(op, left, right);
}
match op {
Operator::Equal
| Operator::NotEqual