mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 01:15:14 +02:00
Series arithmetic (#3602)
* operations with series * contains operations with series * Checked division and masked operations
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user