diff --git a/Cargo.lock b/Cargo.lock index 6bc2d5e1b1..73e782e04c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4666,7 +4666,7 @@ dependencies = [ [[package]] name = "polars" version = "0.14.2" -source = "git+https://github.com/pola-rs/polars?rev=f60d86bc0921bd42635e8a33e7aad28ebe62dc3e#f60d86bc0921bd42635e8a33e7aad28ebe62dc3e" +source = "git+https://github.com/pola-rs/polars?rev=adc358b437f93bc7f844a94d68c064616e9d2ac2#adc358b437f93bc7f844a94d68c064616e9d2ac2" dependencies = [ "polars-core", "polars-io", @@ -4676,7 +4676,7 @@ dependencies = [ [[package]] name = "polars-arrow" version = "0.14.2" -source = "git+https://github.com/pola-rs/polars?rev=f60d86bc0921bd42635e8a33e7aad28ebe62dc3e#f60d86bc0921bd42635e8a33e7aad28ebe62dc3e" +source = "git+https://github.com/pola-rs/polars?rev=adc358b437f93bc7f844a94d68c064616e9d2ac2#adc358b437f93bc7f844a94d68c064616e9d2ac2" dependencies = [ "arrow", "num 0.4.0", @@ -4686,7 +4686,7 @@ dependencies = [ [[package]] name = "polars-core" version = "0.14.2" -source = "git+https://github.com/pola-rs/polars?rev=f60d86bc0921bd42635e8a33e7aad28ebe62dc3e#f60d86bc0921bd42635e8a33e7aad28ebe62dc3e" +source = "git+https://github.com/pola-rs/polars?rev=adc358b437f93bc7f844a94d68c064616e9d2ac2#adc358b437f93bc7f844a94d68c064616e9d2ac2" dependencies = [ "ahash", "anyhow", @@ -4712,7 +4712,7 @@ dependencies = [ [[package]] name = "polars-io" version = "0.14.2" -source = "git+https://github.com/pola-rs/polars?rev=f60d86bc0921bd42635e8a33e7aad28ebe62dc3e#f60d86bc0921bd42635e8a33e7aad28ebe62dc3e" +source = "git+https://github.com/pola-rs/polars?rev=adc358b437f93bc7f844a94d68c064616e9d2ac2#adc358b437f93bc7f844a94d68c064616e9d2ac2" dependencies = [ "ahash", "anyhow", @@ -4735,7 +4735,7 @@ dependencies = [ [[package]] name = "polars-lazy" version = "0.14.2" -source = "git+https://github.com/pola-rs/polars?rev=f60d86bc0921bd42635e8a33e7aad28ebe62dc3e#f60d86bc0921bd42635e8a33e7aad28ebe62dc3e" +source = "git+https://github.com/pola-rs/polars?rev=adc358b437f93bc7f844a94d68c064616e9d2ac2#adc358b437f93bc7f844a94d68c064616e9d2ac2" dependencies = [ "ahash", "itertools", diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml index cd18883c45..383fdb057c 100644 --- a/crates/nu-command/Cargo.toml +++ b/crates/nu-command/Cargo.toml @@ -100,7 +100,7 @@ zip = { version="0.5.9", optional=true } [dependencies.polars] git = "https://github.com/pola-rs/polars" -rev = "f60d86bc0921bd42635e8a33e7aad28ebe62dc3e" +rev = "adc358b437f93bc7f844a94d68c064616e9d2ac2" version = "0.14.2" optional = true features = ["parquet", "json", "random", "pivot", "strings", "is_in"] diff --git a/crates/nu-command/src/commands/dataframe/aggregate.rs b/crates/nu-command/src/commands/dataframe/aggregate.rs index 2c1d48522d..be411e0544 100644 --- a/crates/nu-command/src/commands/dataframe/aggregate.rs +++ b/crates/nu-command/src/commands/dataframe/aggregate.rs @@ -84,7 +84,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Performs an aggregation operation on a dataframe or groupby object" + "[DataFrame, GroupBy, Series] Performs an aggregation operation on a dataframe, groupby or series object" } fn signature(&self) -> Signature { @@ -101,6 +101,11 @@ impl WholeStreamCommand for DataFrame { "quantile value for quantile operation", Some('q'), ) + .switch( + "explicit", + "returns explicit names for groupby aggregations", + Some('e'), + ) } fn run(&self, args: CommandArgs) -> Result { @@ -159,7 +164,13 @@ fn command(mut args: CommandArgs) -> Result { None => groupby, }; - let res = perform_groupby_aggregation(groupby, op, &operation.tag, &agg_span)?; + let res = perform_groupby_aggregation( + groupby, + op, + &operation.tag, + &agg_span, + args.has_flag("explicit"), + )?; Ok(OutputStream::one(NuDataFrame::dataframe_to_value(res, tag))) } @@ -197,8 +208,9 @@ fn perform_groupby_aggregation( operation: Operation, operation_tag: &Tag, agg_span: &Span, + explicit: bool, ) -> Result { - match operation { + let mut res = match operation { Operation::Mean => groupby.mean(), Operation::Sum => groupby.sum(), Operation::Min => groupby.min(), @@ -219,7 +231,42 @@ fn perform_groupby_aggregation( }; parse_polars_error::<&str>(&e, span, None) - }) + })?; + + if !explicit { + let col_names = res + .get_column_names() + .iter() + .map(|name| name.to_string()) + .collect::>(); + + for col in col_names { + let from = match operation { + Operation::Mean => "_mean", + Operation::Sum => "_sum", + Operation::Min => "_min", + Operation::Max => "_max", + Operation::First => "_first", + Operation::Last => "_last", + Operation::Nunique => "_n_unique", + Operation::Quantile(_) => "_quantile", + Operation::Median => "_median", + Operation::Var => "_agg_var", + Operation::Std => "_agg_std", + Operation::Count => "_count", + }; + + let new_col = match col.find(from) { + Some(index) => &col[..index], + None => &col[..], + }; + + res.rename(col.as_str(), new_col) + .expect("Column is always there. Looping with known names"); + } + } + + Ok(res) } fn perform_dataframe_aggregation( @@ -266,7 +313,7 @@ fn perform_series_aggregation( }; let mut data = TaggedDictBuilder::new(operation_tag.clone()); - data.insert_value("mean", value); + data.insert_value(series.name(), value); Ok(data.into_value()) } @@ -282,7 +329,7 @@ fn perform_series_aggregation( }; let mut data = TaggedDictBuilder::new(operation_tag.clone()); - data.insert_value("median", value); + data.insert_value(series.name(), value); Ok(data.into_value()) } @@ -319,7 +366,7 @@ fn perform_series_aggregation( }; let mut data = TaggedDictBuilder::new(operation_tag.clone()); - data.insert_value("sum", value); + data.insert_value(series.name(), value); Ok(data.into_value()) } @@ -356,7 +403,7 @@ fn perform_series_aggregation( }; let mut data = TaggedDictBuilder::new(operation_tag.clone()); - data.insert_value("max", value); + data.insert_value(series.name(), value); Ok(data.into_value()) } @@ -393,7 +440,7 @@ fn perform_series_aggregation( }; let mut data = TaggedDictBuilder::new(operation_tag.clone()); - data.insert_value("min", value); + data.insert_value(series.name(), value); Ok(data.into_value()) } diff --git a/crates/nu-command/src/commands/dataframe/column.rs b/crates/nu-command/src/commands/dataframe/column.rs index 9c7f6d1072..282acad27f 100644 --- a/crates/nu-command/src/commands/dataframe/column.rs +++ b/crates/nu-command/src/commands/dataframe/column.rs @@ -17,7 +17,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Returns the selected column as Series" + "[DataFrame] Returns the selected column as Series" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/drop.rs b/crates/nu-command/src/commands/dataframe/drop.rs index 9e63b05588..fe40991e53 100644 --- a/crates/nu-command/src/commands/dataframe/drop.rs +++ b/crates/nu-command/src/commands/dataframe/drop.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates a new dataframe by dropping the selected columns" + "[DataFrame] Creates a new dataframe by dropping the selected columns" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/drop_duplicates.rs b/crates/nu-command/src/commands/dataframe/drop_duplicates.rs index 2c0d7b33c4..a7ed6ef7fa 100644 --- a/crates/nu-command/src/commands/dataframe/drop_duplicates.rs +++ b/crates/nu-command/src/commands/dataframe/drop_duplicates.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Drops duplicate values in dataframe" + "[DataFrame] Drops duplicate values in dataframe" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/drop_nulls.rs b/crates/nu-command/src/commands/dataframe/drop_nulls.rs index 68558c1e99..5e51632902 100644 --- a/crates/nu-command/src/commands/dataframe/drop_nulls.rs +++ b/crates/nu-command/src/commands/dataframe/drop_nulls.rs @@ -16,7 +16,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Drops null values in dataframe" + "[DataFrame, Series] Drops null values in dataframe" } fn signature(&self) -> Signature { @@ -37,7 +37,7 @@ impl WholeStreamCommand for DataFrame { description: "drop null values in dataframe", example: r#"let df = ([[a b]; [1 2] [3 0] [1 2]] | dataframe to-df); let res = ($df.b / $df.b); -let df = ($df | dataframe with-column $res as res); +let df = ($df | dataframe with-column $res --name res); $df | dataframe drop-nulls "#, result: None, diff --git a/crates/nu-command/src/commands/dataframe/dtypes.rs b/crates/nu-command/src/commands/dataframe/dtypes.rs index 12d4d01071..3ab0b19249 100644 --- a/crates/nu-command/src/commands/dataframe/dtypes.rs +++ b/crates/nu-command/src/commands/dataframe/dtypes.rs @@ -11,7 +11,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Show dataframe data types" + "[DataFrame] Show dataframe data types" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/dummies.rs b/crates/nu-command/src/commands/dataframe/dummies.rs index bd5361233b..9541db3026 100644 --- a/crates/nu-command/src/commands/dataframe/dummies.rs +++ b/crates/nu-command/src/commands/dataframe/dummies.rs @@ -16,7 +16,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates a new dataframe with dummy variables" + "[DataFrame] Creates a new dataframe with dummy variables" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/filter.rs b/crates/nu-command/src/commands/dataframe/filter.rs index 59d11d8a6d..615f5e94ac 100644 --- a/crates/nu-command/src/commands/dataframe/filter.rs +++ b/crates/nu-command/src/commands/dataframe/filter.rs @@ -11,17 +11,19 @@ pub struct DataFrame; impl WholeStreamCommand for DataFrame { fn name(&self) -> &str { - "dataframe filter" + "dataframe filter-with" } fn usage(&self) -> &str { - "Filters dataframe using a mask as reference" + "[DataFrame] Filters dataframe using a mask as reference" } fn signature(&self) -> Signature { - Signature::build("dataframe filter") - .required("with", SyntaxShape::String, "the word 'with'") - .required("mask", SyntaxShape::Any, "boolean mask used to filter data") + Signature::build("dataframe filter-with").required( + "mask", + SyntaxShape::Any, + "boolean mask used to filter data", + ) } fn run(&self, args: CommandArgs) -> Result { @@ -33,13 +35,13 @@ impl WholeStreamCommand for DataFrame { Example { description: "Filter dataframe using a bool mask", example: r#"let mask = ([$true $false] | dataframe to-series); -[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe filter with $mask"#, +[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe filter-with $mask"#, result: None, }, Example { description: "Filter dataframe by creating a mask from operation", example: r#"let mask = (([5 6] | dataframe to-series) > 5); -[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe filter with $mask"#, +[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe filter-with $mask"#, result: None, }, ] @@ -48,7 +50,7 @@ impl WholeStreamCommand for DataFrame { fn command(mut args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); - let value: Value = args.req(1)?; + let value: Value = args.req(0)?; let series_span = value.tag.span; let series = match value.value { diff --git a/crates/nu-command/src/commands/dataframe/get.rs b/crates/nu-command/src/commands/dataframe/get.rs index 0f5be9956e..0b70741fa4 100644 --- a/crates/nu-command/src/commands/dataframe/get.rs +++ b/crates/nu-command/src/commands/dataframe/get.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates dataframe with the selected columns" + "[DataFrame] Creates dataframe with the selected columns" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/groupby.rs b/crates/nu-command/src/commands/dataframe/groupby.rs index e0081898e2..3747e308a8 100644 --- a/crates/nu-command/src/commands/dataframe/groupby.rs +++ b/crates/nu-command/src/commands/dataframe/groupby.rs @@ -16,7 +16,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates a groupby object that can be used for other aggregations" + "[DataFrame] Creates a groupby object that can be used for other aggregations" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/head.rs b/crates/nu-command/src/commands/dataframe/head.rs index 1de35a7756..615b138828 100644 --- a/crates/nu-command/src/commands/dataframe/head.rs +++ b/crates/nu-command/src/commands/dataframe/head.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates new dataframe with head rows" + "[DataFrame] Creates new dataframe with head rows" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/join.rs b/crates/nu-command/src/commands/dataframe/join.rs index 326397273d..8decf80b20 100644 --- a/crates/nu-command/src/commands/dataframe/join.rs +++ b/crates/nu-command/src/commands/dataframe/join.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Joins a dataframe using columns as reference" + "[DataFrame] Joins a dataframe using columns as reference" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/load.rs b/crates/nu-command/src/commands/dataframe/load.rs index 214a1dacb7..7fe3f7369d 100644 --- a/crates/nu-command/src/commands/dataframe/load.rs +++ b/crates/nu-command/src/commands/dataframe/load.rs @@ -208,7 +208,7 @@ fn from_csv(args: CommandArgs) -> Result }; match csv_reader.finish() { - Ok(csv_reader) => Ok(csv_reader), + Ok(df) => Ok(df), Err(e) => Err(parse_polars_error::<&str>(&e, &file.tag.span, None)), } } diff --git a/crates/nu-command/src/commands/dataframe/melt.rs b/crates/nu-command/src/commands/dataframe/melt.rs index 7f5e0ea0e9..7df3f34edf 100644 --- a/crates/nu-command/src/commands/dataframe/melt.rs +++ b/crates/nu-command/src/commands/dataframe/melt.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Unpivot a DataFrame from wide to long format" + "[DataFrame] Unpivot a DataFrame from wide to long format" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/pivot.rs b/crates/nu-command/src/commands/dataframe/pivot.rs index 97c8eb2669..206fa1d58f 100644 --- a/crates/nu-command/src/commands/dataframe/pivot.rs +++ b/crates/nu-command/src/commands/dataframe/pivot.rs @@ -46,7 +46,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Performs a pivot operation on a groupby object" + "[GroupBy] Performs a pivot operation on a groupby object" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/sample.rs b/crates/nu-command/src/commands/dataframe/sample.rs index aadc936f9c..9776eded6b 100644 --- a/crates/nu-command/src/commands/dataframe/sample.rs +++ b/crates/nu-command/src/commands/dataframe/sample.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Create sample dataframe" + "[DataFrame] Create sample dataframe" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/select.rs b/crates/nu-command/src/commands/dataframe/select.rs index 6fe9fa9b16..3b84395d79 100644 --- a/crates/nu-command/src/commands/dataframe/select.rs +++ b/crates/nu-command/src/commands/dataframe/select.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates a new dataframe with the selected columns" + "[DataFrame] Creates a new dataframe with the selected columns" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/all_false.rs b/crates/nu-command/src/commands/dataframe/series/all_false.rs index 1a9f800dcb..110430991b 100644 --- a/crates/nu-command/src/commands/dataframe/series/all_false.rs +++ b/crates/nu-command/src/commands/dataframe/series/all_false.rs @@ -11,7 +11,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Returns true if all values are false" + "[Series] Returns true if all values are false" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/all_true.rs b/crates/nu-command/src/commands/dataframe/series/all_true.rs index 7b2503be72..38f82656b6 100644 --- a/crates/nu-command/src/commands/dataframe/series/all_true.rs +++ b/crates/nu-command/src/commands/dataframe/series/all_true.rs @@ -11,7 +11,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Returns true if all values are true" + "[Series] Returns true if all values are true" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/arg_max.rs b/crates/nu-command/src/commands/dataframe/series/arg_max.rs index dcc3fc6cce..7fac28ca1b 100644 --- a/crates/nu-command/src/commands/dataframe/series/arg_max.rs +++ b/crates/nu-command/src/commands/dataframe/series/arg_max.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Return index for max value in series" + "[Series] Return index for max value in series" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/arg_min.rs b/crates/nu-command/src/commands/dataframe/series/arg_min.rs index ddd9209805..c15ed1a91d 100644 --- a/crates/nu-command/src/commands/dataframe/series/arg_min.rs +++ b/crates/nu-command/src/commands/dataframe/series/arg_min.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Return index for min value in series" + "[Series] Return index for min value in series" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/arg_sort.rs b/crates/nu-command/src/commands/dataframe/series/arg_sort.rs index 3dc9c51770..7be88426b1 100644 --- a/crates/nu-command/src/commands/dataframe/series/arg_sort.rs +++ b/crates/nu-command/src/commands/dataframe/series/arg_sort.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Returns indexes for a sorted series" + "[Series] Returns indexes for a sorted series" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/arg_true.rs b/crates/nu-command/src/commands/dataframe/series/arg_true.rs index 1aac61d132..d4b5a13edf 100644 --- a/crates/nu-command/src/commands/dataframe/series/arg_true.rs +++ b/crates/nu-command/src/commands/dataframe/series/arg_true.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Returns indexes where values are true" + "[Series] Returns indexes where values are true" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/arg_unique.rs b/crates/nu-command/src/commands/dataframe/series/arg_unique.rs index e40eeb23d4..2b096f336c 100644 --- a/crates/nu-command/src/commands/dataframe/series/arg_unique.rs +++ b/crates/nu-command/src/commands/dataframe/series/arg_unique.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Returns indexes for unique values" + "[Series] Returns indexes for unique values" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/is_duplicated.rs b/crates/nu-command/src/commands/dataframe/series/is_duplicated.rs index 002a02be9f..14c2038c95 100644 --- a/crates/nu-command/src/commands/dataframe/series/is_duplicated.rs +++ b/crates/nu-command/src/commands/dataframe/series/is_duplicated.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates mask indicating duplicated values" + "[Series] Creates mask indicating duplicated values" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/is_in.rs b/crates/nu-command/src/commands/dataframe/series/is_in.rs index 64e6cc5cad..8a335d1a97 100644 --- a/crates/nu-command/src/commands/dataframe/series/is_in.rs +++ b/crates/nu-command/src/commands/dataframe/series/is_in.rs @@ -15,7 +15,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Checks if elements from a series are contained in right series" + "[Series] Checks if elements from a series are contained in right series" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/is_not_null.rs b/crates/nu-command/src/commands/dataframe/series/is_not_null.rs index f3ce8cdd03..00da975c6f 100644 --- a/crates/nu-command/src/commands/dataframe/series/is_not_null.rs +++ b/crates/nu-command/src/commands/dataframe/series/is_not_null.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates mask where value is not null" + "[Series] Creates mask where value is not null" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/is_null.rs b/crates/nu-command/src/commands/dataframe/series/is_null.rs index 33a3d9fed4..620d31e3f5 100644 --- a/crates/nu-command/src/commands/dataframe/series/is_null.rs +++ b/crates/nu-command/src/commands/dataframe/series/is_null.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates mask where value is null" + "[Series] Creates mask where value is null" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/is_unique.rs b/crates/nu-command/src/commands/dataframe/series/is_unique.rs index 02369344c3..7c0b73a963 100644 --- a/crates/nu-command/src/commands/dataframe/series/is_unique.rs +++ b/crates/nu-command/src/commands/dataframe/series/is_unique.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates mask indicating unique values" + "[Series] Creates mask indicating unique values" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/n_null.rs b/crates/nu-command/src/commands/dataframe/series/n_null.rs index 6e8eb9f19b..0319f9ffd3 100644 --- a/crates/nu-command/src/commands/dataframe/series/n_null.rs +++ b/crates/nu-command/src/commands/dataframe/series/n_null.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Counts null values" + "[Series] Counts null values" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/n_unique.rs b/crates/nu-command/src/commands/dataframe/series/n_unique.rs index 2181bd44a3..adbb22fc63 100644 --- a/crates/nu-command/src/commands/dataframe/series/n_unique.rs +++ b/crates/nu-command/src/commands/dataframe/series/n_unique.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Counts unique value" + "[Series] Counts unique value" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/rename.rs b/crates/nu-command/src/commands/dataframe/series/rename.rs index a3c9730b36..b5804f90d9 100644 --- a/crates/nu-command/src/commands/dataframe/series/rename.rs +++ b/crates/nu-command/src/commands/dataframe/series/rename.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Renames a series" + "[Series] Renames a series" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/set.rs b/crates/nu-command/src/commands/dataframe/series/set.rs index f24b3ed3c3..f3915299b7 100644 --- a/crates/nu-command/src/commands/dataframe/series/set.rs +++ b/crates/nu-command/src/commands/dataframe/series/set.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Sets value where given mask is true" + "[Series] Sets value where given mask is true" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/shift.rs b/crates/nu-command/src/commands/dataframe/series/shift.rs index 816a2ef927..b02575bc9e 100644 --- a/crates/nu-command/src/commands/dataframe/series/shift.rs +++ b/crates/nu-command/src/commands/dataframe/series/shift.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Shifts the values by a given period" + "[Series] Shifts the values by a given period" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/unique.rs b/crates/nu-command/src/commands/dataframe/series/unique.rs index 371e820002..ebf1e84888 100644 --- a/crates/nu-command/src/commands/dataframe/series/unique.rs +++ b/crates/nu-command/src/commands/dataframe/series/unique.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Returns unique values from a series" + "[Series] Returns unique values from a series" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/series/value_counts.rs b/crates/nu-command/src/commands/dataframe/series/value_counts.rs index 71b797e29e..843acff1a3 100644 --- a/crates/nu-command/src/commands/dataframe/series/value_counts.rs +++ b/crates/nu-command/src/commands/dataframe/series/value_counts.rs @@ -16,7 +16,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Returns a dataframe with the counts for unique values in series" + "[Series] Returns a dataframe with the counts for unique values in series" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/show.rs b/crates/nu-command/src/commands/dataframe/show.rs index 0e56b06300..93cc47e1d5 100644 --- a/crates/nu-command/src/commands/dataframe/show.rs +++ b/crates/nu-command/src/commands/dataframe/show.rs @@ -13,7 +13,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Converts a section of the dataframe to a Table or List value" + "[DataFrame] Converts a section of the dataframe to a Table or List value" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/slice.rs b/crates/nu-command/src/commands/dataframe/slice.rs index a0d861fc21..8734fd3398 100644 --- a/crates/nu-command/src/commands/dataframe/slice.rs +++ b/crates/nu-command/src/commands/dataframe/slice.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates new dataframe from a slice of rows" + "[DataFrame] Creates new dataframe from a slice of rows" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/sort.rs b/crates/nu-command/src/commands/dataframe/sort.rs index 9fa7b845d0..b4f09b2516 100644 --- a/crates/nu-command/src/commands/dataframe/sort.rs +++ b/crates/nu-command/src/commands/dataframe/sort.rs @@ -15,7 +15,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates new sorted dataframe or series" + "[DataFrame, Series] Creates new sorted dataframe or series" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/tail.rs b/crates/nu-command/src/commands/dataframe/tail.rs index e4311bbf36..2eb3612649 100644 --- a/crates/nu-command/src/commands/dataframe/tail.rs +++ b/crates/nu-command/src/commands/dataframe/tail.rs @@ -12,7 +12,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Creates new dataframe with tail rows" + "[DataFrame] Creates new dataframe with tail rows" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/to_csv.rs b/crates/nu-command/src/commands/dataframe/to_csv.rs index 0eb42b8412..b142dc7d7a 100644 --- a/crates/nu-command/src/commands/dataframe/to_csv.rs +++ b/crates/nu-command/src/commands/dataframe/to_csv.rs @@ -22,7 +22,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Saves dataframe to csv file" + "[DataFrame] Saves dataframe to csv file" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/to_parquet.rs b/crates/nu-command/src/commands/dataframe/to_parquet.rs index ce63f9f787..4982c86a02 100644 --- a/crates/nu-command/src/commands/dataframe/to_parquet.rs +++ b/crates/nu-command/src/commands/dataframe/to_parquet.rs @@ -20,7 +20,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Saves dataframe to parquet file" + "[DataFrame] Saves dataframe to parquet file" } fn signature(&self) -> Signature { diff --git a/crates/nu-command/src/commands/dataframe/where_.rs b/crates/nu-command/src/commands/dataframe/where_.rs index eacd53e547..96f6ac71cd 100644 --- a/crates/nu-command/src/commands/dataframe/where_.rs +++ b/crates/nu-command/src/commands/dataframe/where_.rs @@ -26,7 +26,7 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Filter dataframe to match the condition" + "[DataFrame] Filter dataframe to match the condition" } fn run(&self, args: CommandArgs) -> Result { diff --git a/crates/nu-command/src/commands/dataframe/with_column.rs b/crates/nu-command/src/commands/dataframe/with_column.rs index 72689019f1..a0fdef26be 100644 --- a/crates/nu-command/src/commands/dataframe/with_column.rs +++ b/crates/nu-command/src/commands/dataframe/with_column.rs @@ -16,14 +16,13 @@ impl WholeStreamCommand for DataFrame { } fn usage(&self) -> &str { - "Adds a series to the dataframe" + "[DataFrame] Adds a series to the dataframe" } fn signature(&self) -> Signature { Signature::build("dataframe with-column") .required("series", SyntaxShape::Any, "series to be added") - .required("as", SyntaxShape::String, "the word 'as'") - .required("name", SyntaxShape::String, "column name") + .required_named("name", SyntaxShape::String, "column name", Some('n')) } fn run(&self, args: CommandArgs) -> Result { @@ -34,7 +33,7 @@ impl WholeStreamCommand for DataFrame { vec![Example { description: "Adds a series to the dataframe", example: - "[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe with-column ([5 6] | dataframe to-series) as c", + "[[a b]; [1 2] [3 4]] | dataframe to-df | dataframe with-column ([5 6] | dataframe to-series) --name c", result: None, }] } @@ -43,7 +42,7 @@ impl WholeStreamCommand for DataFrame { fn command(mut args: CommandArgs) -> Result { let tag = args.call_info.name_tag.clone(); let value: Value = args.req(0)?; - let name: Tagged = args.req(2)?; + let name: Tagged = args.req_named("name")?; let mut series = match value.value { UntaggedValue::DataFrame(PolarsData::Series(series)) => Ok(series), diff --git a/crates/nu-data/Cargo.toml b/crates/nu-data/Cargo.toml index 722082bd8e..34fa292bd2 100644 --- a/crates/nu-data/Cargo.toml +++ b/crates/nu-data/Cargo.toml @@ -39,7 +39,7 @@ nu-ansi-term = { version="0.33.1", path="../nu-ansi-term" } [dependencies.polars] git = "https://github.com/pola-rs/polars" -rev = "f60d86bc0921bd42635e8a33e7aad28ebe62dc3e" +rev = "adc358b437f93bc7f844a94d68c064616e9d2ac2" version = "0.14.2" optional = true features = ["strings", "checked_arithmetic"] diff --git a/crates/nu-protocol/Cargo.toml b/crates/nu-protocol/Cargo.toml index 0d1067b593..24277a1e17 100644 --- a/crates/nu-protocol/Cargo.toml +++ b/crates/nu-protocol/Cargo.toml @@ -32,7 +32,7 @@ toml = "0.5.8" [dependencies.polars] git = "https://github.com/pola-rs/polars" -rev = "f60d86bc0921bd42635e8a33e7aad28ebe62dc3e" +rev = "adc358b437f93bc7f844a94d68c064616e9d2ac2" version = "0.14.2" optional = true features = ["serde", "rows"]