Standardise to commands (#5800)

* standarize to commands

* move from to to into
This commit is contained in:
Fernando Herrera 2022-06-17 07:51:50 -05:00 committed by GitHub
parent 5f0ad1d6ad
commit 6cc8402127
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
85 changed files with 178 additions and 145 deletions

View file

@ -30,7 +30,7 @@ impl Command for AppendDF {
vec![ vec![
Example { Example {
description: "Appends a dataframe as new columns", description: "Appends a dataframe as new columns",
example: r#"let a = ([[a b]; [1 2] [3 4]] | to-df); example: r#"let a = ([[a b]; [1 2] [3 4]] | into df);
$a | append $a"#, $a | append $a"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
@ -57,7 +57,7 @@ impl Command for AppendDF {
}, },
Example { Example {
description: "Appends a dataframe merging at the end of columns", description: "Appends a dataframe merging at the end of columns",
example: r#"let a = ([[a b]; [1 2] [3 4]] | to-df); example: r#"let a = ([[a b]; [1 2] [3 4]] | into df);
$a | append $a --col"#, $a | append $a --col"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![

View file

@ -40,7 +40,7 @@ impl Command for DescribeDF {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "dataframe description", description: "dataframe description",
example: "[[a b]; [1 1] [1 1]] | to-df | describe", example: "[[a b]; [1 1] [1 1]] | into df | describe",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(

View file

@ -29,7 +29,7 @@ impl Command for DropDF {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "drop column a", description: "drop column a",
example: "[[a b]; [1 2] [3 4]] | to-df | drop a", example: "[[a b]; [1 2] [3 4]] | into df | drop a",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"b".to_string(), "b".to_string(),

View file

@ -40,7 +40,7 @@ impl Command for DropDuplicates {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "drop duplicates", description: "drop duplicates",
example: "[[a b]; [1 2] [3 4] [1 2]] | to-df | drop-duplicates", example: "[[a b]; [1 2] [3 4] [1 2]] | into df | drop-duplicates",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(

View file

@ -34,7 +34,7 @@ impl Command for DropNulls {
vec![ vec![
Example { Example {
description: "drop null values in dataframe", description: "drop null values in dataframe",
example: r#"let df = ([[a b]; [1 2] [3 0] [1 2]] | to-df); example: r#"let df = ([[a b]; [1 2] [3 0] [1 2]] | into df);
let res = ($df.b / $df.b); let res = ($df.b / $df.b);
let a = ($df | with-column $res --name res); let a = ($df | with-column $res --name res);
$a | drop-nulls"#, $a | drop-nulls"#,
@ -59,7 +59,7 @@ impl Command for DropNulls {
}, },
Example { Example {
description: "drop null values in dataframe", description: "drop null values in dataframe",
example: r#"let s = ([1 2 0 0 3 4] | to-df); example: r#"let s = ([1 2 0 0 3 4] | into df);
($s / $s) | drop-nulls"#, ($s / $s) | drop-nulls"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -24,7 +24,7 @@ impl Command for DataTypes {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Dataframe dtypes", description: "Dataframe dtypes",
example: "[[a b]; [1 2] [3 4]] | to-df | dtypes", example: "[[a b]; [1 2] [3 4]] | into df | dtypes",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(

View file

@ -11,7 +11,7 @@ pub struct Dummies;
impl Command for Dummies { impl Command for Dummies {
fn name(&self) -> &str { fn name(&self) -> &str {
"to-dummies" "dummies"
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
@ -26,7 +26,7 @@ impl Command for Dummies {
vec![ vec![
Example { Example {
description: "Create new dataframe with dummy variables from a dataframe", description: "Create new dataframe with dummy variables from a dataframe",
example: "[[a b]; [1 2] [3 4]] | to-df | to-dummies", example: "[[a b]; [1 2] [3 4]] | into df | dummies",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(
@ -52,7 +52,7 @@ impl Command for Dummies {
}, },
Example { Example {
description: "Create new dataframe with dummy variables from a series", description: "Create new dataframe with dummy variables from a series",
example: "[1 2 2 3 3] | to-df | to-dummies", example: "[1 2 2 3 3] | into df | dummies",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(

View file

@ -36,8 +36,8 @@ impl Command for FilterWith {
vec![ vec![
Example { Example {
description: "Filter dataframe using a bool mask", description: "Filter dataframe using a bool mask",
example: r#"let mask = ([true false] | to-df); example: r#"let mask = ([true false] | into df);
[[a b]; [1 2] [3 4]] | to-df | filter-with $mask"#, [[a b]; [1 2] [3 4]] | into df | filter-with $mask"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(1)]), Column::new("a".to_string(), vec![Value::test_int(1)]),
@ -49,7 +49,7 @@ impl Command for FilterWith {
}, },
Example { Example {
description: "Filter dataframe using an expression", description: "Filter dataframe using an expression",
example: "[[a b]; [1 2] [3 4]] | to-df | filter-with ((col a) > 1)", example: "[[a b]; [1 2] [3 4]] | into df | filter-with ((col a) > 1)",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(3)]), Column::new("a".to_string(), vec![Value::test_int(3)]),

View file

@ -27,7 +27,7 @@ impl Command for FirstDF {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Create new dataframe with head rows", description: "Create new dataframe with head rows",
example: "[[a b]; [1 2] [3 4]] | to-df | first 1", example: "[[a b]; [1 2] [3 4]] | into df | first 1",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(1)]), Column::new("a".to_string(), vec![Value::test_int(1)]),

View file

@ -30,7 +30,7 @@ impl Command for GetDF {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Returns the selected column", description: "Returns the selected column",
example: "[[a b]; [1 2] [3 4]] | to-df | get a", example: "[[a b]; [1 2] [3 4]] | into df | get a",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"a".to_string(), "a".to_string(),

View file

@ -27,7 +27,7 @@ impl Command for LastDF {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Create new dataframe with last rows", description: "Create new dataframe with last rows",
example: "[[a b]; [1 2] [3 4]] | to-df | last 1", example: "[[a b]; [1 2] [3 4]] | into df | last 1",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(3)]), Column::new("a".to_string(), vec![Value::test_int(3)]),

View file

@ -25,7 +25,7 @@ impl Command for ListDF {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Creates a new dataframe and shows it in the dataframe list", description: "Creates a new dataframe and shows it in the dataframe list",
example: r#"let test = ([[a b];[1 2] [3 4]] | to-df); example: r#"let test = ([[a b];[1 2] [3 4]] | into df);
ls-df"#, ls-df"#,
result: None, result: None,
}] }]

View file

@ -54,7 +54,8 @@ impl Command for MeltDF {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "melt dataframe", description: "melt dataframe",
example: "[[a b c d]; [x 1 4 a] [y 2 5 b] [z 3 6 c]] | to-df | melt -c [b c] -v [a d]", example:
"[[a b c d]; [x 1 4 a] [y 2 5 b] [z 3 6 c]] | into df | melt -c [b c] -v [a d]",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(

View file

@ -40,7 +40,7 @@ impl Command for RenameDF {
vec![ vec![
Example { Example {
description: "Renames a series", description: "Renames a series",
example: "[5 6 7 8] | to-df | rename '0' new_name", example: "[5 6 7 8] | into df | rename '0' new_name",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"new_name".to_string(), "new_name".to_string(),
@ -57,7 +57,7 @@ impl Command for RenameDF {
}, },
Example { Example {
description: "Renames a dataframe column", description: "Renames a dataframe column",
example: "[[a b]; [1 2] [3 4]] | to-df | rename a a_new", example: "[[a b]; [1 2] [3 4]] | into df | rename a a_new",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(
@ -75,7 +75,7 @@ impl Command for RenameDF {
}, },
Example { Example {
description: "Renames two dataframe columns", description: "Renames two dataframe columns",
example: "[[a b]; [1 2] [3 4]] | to-df | rename [a b] [a_new b_new]", example: "[[a b]; [1 2] [3 4]] | into df | rename [a b] [a_new b_new]",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(

View file

@ -48,12 +48,12 @@ impl Command for SampleDF {
vec![ vec![
Example { Example {
description: "Sample rows from dataframe", description: "Sample rows from dataframe",
example: "[[a b]; [1 2] [3 4]] | to-df | sample -n 1", example: "[[a b]; [1 2] [3 4]] | into df | sample -n 1",
result: None, // No expected value because sampling is random result: None, // No expected value because sampling is random
}, },
Example { Example {
description: "Shows sample row using fraction and replace", description: "Shows sample row using fraction and replace",
example: "[[a b]; [1 2] [3 4] [5 6]] | to-df | sample -f 0.5 -e", example: "[[a b]; [1 2] [3 4] [5 6]] | into df | sample -f 0.5 -e",
result: None, // No expected value because sampling is random result: None, // No expected value because sampling is random
}, },
] ]

View file

@ -27,7 +27,7 @@ impl Command for ShapeDF {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Shows row and column shape", description: "Shows row and column shape",
example: "[[a b]; [1 2] [3 4]] | to-df | shape", example: "[[a b]; [1 2] [3 4]] | into df | shape",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("rows".to_string(), vec![Value::test_int(2)]), Column::new("rows".to_string(), vec![Value::test_int(2)]),

View file

@ -31,7 +31,7 @@ impl Command for SliceDF {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Create new dataframe from a slice of the rows", description: "Create new dataframe from a slice of the rows",
example: "[[a b]; [1 2] [3 4]] | to-df | slice 0 1", example: "[[a b]; [1 2] [3 4]] | into df | slice 0 1",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(1)]), Column::new("a".to_string(), vec![Value::test_int(1)]),

View file

@ -36,8 +36,8 @@ impl Command for TakeDF {
vec![ vec![
Example { Example {
description: "Takes selected rows from dataframe", description: "Takes selected rows from dataframe",
example: r#"let df = ([[a b]; [4 1] [5 2] [4 3]] | to-df); example: r#"let df = ([[a b]; [4 1] [5 2] [4 3]] | into df);
let indices = ([0 2] | to-df); let indices = ([0 2] | into df);
$df | take $indices"#, $df | take $indices"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
@ -56,8 +56,8 @@ impl Command for TakeDF {
}, },
Example { Example {
description: "Takes selected rows from series", description: "Takes selected rows from series",
example: r#"let series = ([4 1 5 2 4 3] | to-df); example: r#"let series = ([4 1 5 2 4 3] | into df);
let indices = ([0 2] | to-df); let indices = ([0 2] | into df);
$series | take $indices"#, $series | take $indices"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -15,7 +15,7 @@ pub struct ToCSV;
impl Command for ToCSV { impl Command for ToCSV {
fn name(&self) -> &str { fn name(&self) -> &str {
"to-csv" "to csv"
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
@ -39,12 +39,12 @@ impl Command for ToCSV {
vec![ vec![
Example { Example {
description: "Saves dataframe to csv file", description: "Saves dataframe to csv file",
example: "[[a b]; [1 2] [3 4]] | to-df | to-csv test.csv", example: "[[a b]; [1 2] [3 4]] | into df | to csv test.csv",
result: None, result: None,
}, },
Example { Example {
description: "Saves dataframe to csv file using other delimiter", description: "Saves dataframe to csv file using other delimiter",
example: "[[a b]; [1 2] [3 4]] | to-df | to-csv test.csv -d '|'", example: "[[a b]; [1 2] [3 4]] | into df | to csv test.csv -d '|'",
result: None, result: None,
}, },
] ]

View file

@ -11,7 +11,7 @@ pub struct ToDataFrame;
impl Command for ToDataFrame { impl Command for ToDataFrame {
fn name(&self) -> &str { fn name(&self) -> &str {
"to-df" "into df"
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
@ -26,7 +26,7 @@ impl Command for ToDataFrame {
vec![ vec![
Example { Example {
description: "Takes a dictionary and creates a dataframe", description: "Takes a dictionary and creates a dataframe",
example: "[[a b];[1 2] [3 4]] | to-df", example: "[[a b];[1 2] [3 4]] | into df",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(
@ -44,7 +44,7 @@ impl Command for ToDataFrame {
}, },
Example { Example {
description: "Takes a list of tables and creates a dataframe", description: "Takes a list of tables and creates a dataframe",
example: "[[1 2 a] [3 4 b] [5 6 c]] | to-df", example: "[[1 2 a] [3 4 b] [5 6 c]] | into df",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(
@ -70,7 +70,7 @@ impl Command for ToDataFrame {
}, },
Example { Example {
description: "Takes a list and creates a dataframe", description: "Takes a list and creates a dataframe",
example: "[a b c] | to-df", example: "[a b c] | into df",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),
@ -86,7 +86,7 @@ impl Command for ToDataFrame {
}, },
Example { Example {
description: "Takes a list of booleans and creates a dataframe", description: "Takes a list of booleans and creates a dataframe",
example: "[true true false] | to-df", example: "[true true false] | into df",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -2,7 +2,7 @@ use nu_engine::CallExt;
use nu_protocol::{ use nu_protocol::{
ast::Call, ast::Call,
engine::{Command, EngineState, Stack}, engine::{Command, EngineState, Stack},
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
}; };
use super::super::values::NuDataFrame; use super::super::values::NuDataFrame;
@ -12,11 +12,11 @@ pub struct ToNu;
impl Command for ToNu { impl Command for ToNu {
fn name(&self) -> &str { fn name(&self) -> &str {
"to-nu" "into nu"
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
"Converts a section of the dataframe to Nushell Table" "Converts a section of the dataframe into nushell Table"
} }
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
@ -32,16 +32,34 @@ impl Command for ToNu {
} }
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
let cols = vec!["a".into(), "b".into()];
let rec_1 = Value::Record {
cols: cols.clone(),
vals: vec![Value::test_int(1), Value::test_int(2)],
span: Span::test_data(),
};
let rec_2 = Value::Record {
cols,
vals: vec![Value::test_int(3), Value::test_int(4)],
span: Span::test_data(),
};
vec![ vec![
Example { Example {
description: "Shows head rows from dataframe", description: "Shows head rows from dataframe",
example: "[[a b]; [1 2] [3 4]] | to-df | to nu", example: "[[a b]; [1 2] [3 4]] | into df | into nu",
result: None, result: Some(Value::List {
vals: vec![rec_1, rec_2.clone()],
span: Span::test_data(),
}),
}, },
Example { Example {
description: "Shows tail rows from dataframe", description: "Shows tail rows from dataframe",
example: "[[a b]; [1 2] [3 4] [5 6]] | to-df | to nu -t -n 1", example: "[[a b]; [1 2] [5 6] [3 4]] | into df | into nu -t -n 1",
result: None, result: Some(Value::List {
vals: vec![rec_2],
span: Span::test_data(),
}),
}, },
] ]
} }
@ -71,7 +89,7 @@ fn command(
call: &Call, call: &Call,
input: PipelineData, input: PipelineData,
) -> Result<PipelineData, ShellError> { ) -> Result<PipelineData, ShellError> {
let rows: Option<usize> = call.get_flag(engine_state, stack, "n-rows")?; let rows: Option<usize> = call.get_flag(engine_state, stack, "rows")?;
let tail: bool = call.has_flag("tail"); let tail: bool = call.has_flag("tail");
let df = NuDataFrame::try_from_pipeline(input, call.head)?; let df = NuDataFrame::try_from_pipeline(input, call.head)?;
@ -87,6 +105,8 @@ fn command(
} }
}; };
println!("len: {}", values.len());
let value = Value::List { let value = Value::List {
vals: values, vals: values,
span: call.head, span: call.head,
@ -94,3 +114,14 @@ fn command(
Ok(PipelineData::Value(value, None)) Ok(PipelineData::Value(value, None))
} }
#[cfg(test)]
mod test {
use super::super::super::test_dataframe::test_dataframe;
use super::*;
#[test]
fn test_examples() {
test_dataframe(vec![Box::new(ToNu {})])
}
}

View file

@ -15,7 +15,7 @@ pub struct ToParquet;
impl Command for ToParquet { impl Command for ToParquet {
fn name(&self) -> &str { fn name(&self) -> &str {
"to-parquet" "to parquet"
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
@ -31,7 +31,7 @@ impl Command for ToParquet {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Saves dataframe to parquet file", description: "Saves dataframe to parquet file",
example: "[[a b]; [1 2] [3 4]] | to-df | to-parquet test.parquet", example: "[[a b]; [1 2] [3 4]] | into df | to parquet test.parquet",
result: None, result: None,
}] }]
} }

View file

@ -35,8 +35,8 @@ impl Command for WithColumn {
Example { Example {
description: "Adds a series to the dataframe", description: "Adds a series to the dataframe",
example: r#"[[a b]; [1 2] [3 4]] example: r#"[[a b]; [1 2] [3 4]]
| to-df | into df
| with-column ([5 6] | to-df) --name c"#, | with-column ([5 6] | into df) --name c"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(
@ -59,7 +59,7 @@ impl Command for WithColumn {
Example { Example {
description: "Adds a series to the dataframe", description: "Adds a series to the dataframe",
example: r#"[[a b]; [1 2] [3 4]] example: r#"[[a b]; [1 2] [3 4]]
| to-lazy | into lazy
| with-column [ | with-column [
((col a) * 2 | as "c") ((col a) * 2 | as "c")
((col a) * 3 | as "d") ((col a) * 3 | as "d")

View file

@ -32,7 +32,7 @@ impl Command for ExprAlias {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Creates and alias expression", description: "Creates and alias expression",
example: "col a | as new_a | to-nu", example: "col a | as new_a | into nu",
result: { result: {
let cols = vec!["expr".into(), "value".into()]; let cols = vec!["expr".into(), "value".into()];
let expr = Value::test_string("column"); let expr = Value::test_string("column");

View file

@ -11,11 +11,11 @@ pub struct ExprAsNu;
impl Command for ExprAsNu { impl Command for ExprAsNu {
fn name(&self) -> &str { fn name(&self) -> &str {
"to-nu" "into nu"
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
"Convert expression to a nu value for access and exploration" "Convert expression into a nu value for access and exploration"
} }
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
@ -25,7 +25,7 @@ impl Command for ExprAsNu {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Convert a col expression into a nushell value", description: "Convert a col expression into a nushell value",
example: "col a | to-nu", example: "col a | into nu",
result: Some(Value::Record { result: Some(Value::Record {
cols: vec!["expr".into(), "value".into()], cols: vec!["expr".into(), "value".into()],
vals: vec![ vals: vec![

View file

@ -32,7 +32,7 @@ impl Command for ExprCol {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Creates a named column expression and converts it to a nu object", description: "Creates a named column expression and converts it to a nu object",
example: "col a | to-nu", example: "col a | into nu",
result: Some(Value::Record { result: Some(Value::Record {
cols: vec!["expr".into(), "value".into()], cols: vec!["expr".into(), "value".into()],
vals: vec![ vals: vec![

View file

@ -250,7 +250,7 @@ expr_command!(
vec![Example { vec![Example {
description: "Max aggregation for a group by", description: "Max aggregation for a group by",
example: r#"[[a b]; [one 2] [one 4] [two 1]] example: r#"[[a b]; [one 2] [one 4] [two 1]]
| to-df | into df
| group-by a | group-by a
| agg (col b | max)"#, | agg (col b | max)"#,
result: Some( result: Some(
@ -281,7 +281,7 @@ expr_command!(
vec![Example { vec![Example {
description: "Min aggregation for a group by", description: "Min aggregation for a group by",
example: r#"[[a b]; [one 2] [one 4] [two 1]] example: r#"[[a b]; [one 2] [one 4] [two 1]]
| to-df | into df
| group-by a | group-by a
| agg (col b | min)"#, | agg (col b | min)"#,
result: Some( result: Some(
@ -312,7 +312,7 @@ expr_command!(
vec![Example { vec![Example {
description: "Sum aggregation for a group by", description: "Sum aggregation for a group by",
example: r#"[[a b]; [one 2] [one 4] [two 1]] example: r#"[[a b]; [one 2] [one 4] [two 1]]
| to-df | into df
| group-by a | group-by a
| agg (col b | sum)"#, | agg (col b | sum)"#,
result: Some( result: Some(
@ -343,7 +343,7 @@ expr_command!(
vec![Example { vec![Example {
description: "Mean aggregation for a group by", description: "Mean aggregation for a group by",
example: r#"[[a b]; [one 2] [one 4] [two 1]] example: r#"[[a b]; [one 2] [one 4] [two 1]]
| to-df | into df
| group-by a | group-by a
| agg (col b | mean)"#, | agg (col b | mean)"#,
result: Some( result: Some(
@ -374,7 +374,7 @@ expr_command!(
vec![Example { vec![Example {
description: "Median aggregation for a group by", description: "Median aggregation for a group by",
example: r#"[[a b]; [one 2] [one 4] [two 1]] example: r#"[[a b]; [one 2] [one 4] [two 1]]
| to-df | into df
| group-by a | group-by a
| agg (col b | median)"#, | agg (col b | median)"#,
result: Some( result: Some(
@ -405,7 +405,7 @@ expr_command!(
vec![Example { vec![Example {
description: "Std aggregation for a group by", description: "Std aggregation for a group by",
example: r#"[[a b]; [one 2] [one 2] [two 1] [two 1]] example: r#"[[a b]; [one 2] [one 2] [two 1] [two 1]]
| to-df | into df
| group-by a | group-by a
| agg (col b | std)"#, | agg (col b | std)"#,
result: Some( result: Some(
@ -436,7 +436,7 @@ expr_command!(
vec![Example { vec![Example {
description: "Var aggregation for a group by", description: "Var aggregation for a group by",
example: r#"[[a b]; [one 2] [one 2] [two 1] [two 1]] example: r#"[[a b]; [one 2] [one 2] [two 1] [two 1]]
| to-df | into df
| group-by a | group-by a
| agg (col b | var)"#, | agg (col b | var)"#,
result: Some( result: Some(

View file

@ -31,7 +31,7 @@ impl Command for ExprLit {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Created a literal expression and converts it to a nu object", description: "Created a literal expression and converts it to a nu object",
example: "lit 2 | to-nu", example: "lit 2 | into nu",
result: Some(Value::Record { result: Some(Value::Record {
cols: vec!["expr".into(), "value".into()], cols: vec!["expr".into(), "value".into()],
vals: vec![ vals: vec![

View file

@ -43,7 +43,7 @@ impl Command for ExprOtherwise {
Example { Example {
description: "Create a new column for the dataframe", description: "Create a new column for the dataframe",
example: r#"[[a b]; [6 2] [1 4] [4 1]] example: r#"[[a b]; [6 2] [1 4] [4 1]]
| to-lazy | into lazy
| with-column ( | with-column (
when ((col a) > 2) 4 | otherwise 5 | as c when ((col a) > 2) 4 | otherwise 5 | as c
) )

View file

@ -33,7 +33,7 @@ impl Command for ExprQuantile {
vec![Example { vec![Example {
description: "Quantile aggregation for a group by", description: "Quantile aggregation for a group by",
example: r#"[[a b]; [one 2] [one 4] [two 1]] example: r#"[[a b]; [one 2] [one 4] [two 1]]
| to-df | into df
| group-by a | group-by a
| agg (col b | quantile 0.5)"#, | agg (col b | quantile 0.5)"#,
result: Some( result: Some(

View file

@ -49,7 +49,7 @@ impl Command for ExprWhen {
Example { Example {
description: "Create a new column for the dataframe", description: "Create a new column for the dataframe",
example: r#"[[a b]; [6 2] [1 4] [4 1]] example: r#"[[a b]; [6 2] [1 4] [4 1]]
| to-lazy | into lazy
| with-column ( | with-column (
when ((col a) > 2) 4 | otherwise 5 | as c when ((col a) > 2) 4 | otherwise 5 | as c
) )

View file

@ -34,7 +34,7 @@ impl Command for LazyAggregate {
Example { Example {
description: "Group by and perform an aggregation", description: "Group by and perform an aggregation",
example: r#"[[a b]; [1 2] [1 4] [2 6] [2 4]] example: r#"[[a b]; [1 2] [1 4] [2 6] [2 4]]
| to-df | into df
| group-by a | group-by a
| agg [ | agg [
(col b | min | as "b_min") (col b | min | as "b_min")
@ -67,7 +67,7 @@ impl Command for LazyAggregate {
Example { Example {
description: "Group by and perform an aggregation", description: "Group by and perform an aggregation",
example: r#"[[a b]; [1 2] [1 4] [2 6] [2 4]] example: r#"[[a b]; [1 2] [1 4] [2 6] [2 4]]
| to-lazy | into lazy
| group-by a | group-by a
| agg [ | agg [
(col b | min | as "b_min") (col b | min | as "b_min")

View file

@ -26,7 +26,7 @@ impl Command for LazyCollect {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "drop duplicates", description: "drop duplicates",
example: "[[a b]; [1 2] [3 4]] | to-lazy | collect", example: "[[a b]; [1 2] [3 4]] | into lazy | collect",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(

View file

@ -32,7 +32,7 @@ impl Command for LazyFetch {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Fetch a rows from the dataframe", description: "Fetch a rows from the dataframe",
example: "[[a b]; [6 2] [4 2] [2 2]] | to-df | fetch 2", example: "[[a b]; [6 2] [4 2] [2 2]] | into df | fetch 2",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(

View file

@ -31,7 +31,7 @@ impl Command for LazyFillNull {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Fills the null values by 0", description: "Fills the null values by 0",
example: "[1 2 2 3 3] | to-df | shift 2 | fill-null 0", example: "[1 2 2 3 3] | into df | shift 2 | fill-null 0",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -34,7 +34,7 @@ impl Command for ToLazyGroupBy {
Example { Example {
description: "Group by and perform an aggregation", description: "Group by and perform an aggregation",
example: r#"[[a b]; [1 2] [1 4] [2 6] [2 4]] example: r#"[[a b]; [1 2] [1 4] [2 6] [2 4]]
| to-df | into df
| group-by a | group-by a
| agg [ | agg [
(col b | min | as "b_min") (col b | min | as "b_min")
@ -67,7 +67,7 @@ impl Command for ToLazyGroupBy {
Example { Example {
description: "Group by and perform an aggregation", description: "Group by and perform an aggregation",
example: r#"[[a b]; [1 2] [1 4] [2 6] [2 4]] example: r#"[[a b]; [1 2] [1 4] [2 6] [2 4]]
| to-lazy | into lazy
| group-by a | group-by a
| agg [ | agg [
(col b | min | as "b_min") (col b | min | as "b_min")

View file

@ -45,8 +45,8 @@ impl Command for LazyJoin {
vec![ vec![
Example { Example {
description: "Join two lazy dataframes", description: "Join two lazy dataframes",
example: r#"let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | to-lazy); example: r#"let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | into lazy);
let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | to-lazy); let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | into lazy);
$df_a | join $df_b a foo | collect"#, $df_a | join $df_b a foo | collect"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
@ -102,8 +102,8 @@ impl Command for LazyJoin {
}, },
Example { Example {
description: "Join one eager dataframe with a lazy dataframe", description: "Join one eager dataframe with a lazy dataframe",
example: r#"let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | to-df); example: r#"let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | into df);
let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | to-lazy); let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | into lazy);
$df_a | join $df_b a foo"#, $df_a | join $df_b a foo"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![

View file

@ -73,7 +73,7 @@ lazy_command!(
"Reverses the LazyFrame", "Reverses the LazyFrame",
vec![Example { vec![Example {
description: "Reverses the dataframe", description: "Reverses the dataframe",
example: "[[a b]; [6 2] [4 2] [2 2]] | to-df | reverse", example: "[[a b]; [6 2] [4 2] [2 2]] | into df | reverse",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(
@ -101,7 +101,7 @@ lazy_command!(
"Caches operations in a new LazyFrame", "Caches operations in a new LazyFrame",
vec![Example { vec![Example {
description: "Caches the result into a new LazyFrame", description: "Caches the result into a new LazyFrame",
example: "[[a b]; [6 2] [4 2] [2 2]] | to-df | reverse | cache", example: "[[a b]; [6 2] [4 2] [2 2]] | into df | reverse | cache",
result: None, result: None,
}], }],
cache, cache,
@ -116,7 +116,7 @@ lazy_command!(
"Aggregates columns to their max value", "Aggregates columns to their max value",
vec![Example { vec![Example {
description: "Max value from columns in a dataframe", description: "Max value from columns in a dataframe",
example: "[[a b]; [6 2] [1 4] [4 1]] | to-df | max", example: "[[a b]; [6 2] [1 4] [4 1]] | into df | max",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(6)],), Column::new("a".to_string(), vec![Value::test_int(6)],),
@ -138,7 +138,7 @@ lazy_command!(
"Aggregates columns to their min value", "Aggregates columns to their min value",
vec![Example { vec![Example {
description: "Min value from columns in a dataframe", description: "Min value from columns in a dataframe",
example: "[[a b]; [6 2] [1 4] [4 1]] | to-df | min", example: "[[a b]; [6 2] [1 4] [4 1]] | into df | min",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(1)],), Column::new("a".to_string(), vec![Value::test_int(1)],),
@ -160,7 +160,7 @@ lazy_command!(
"Aggregates columns to their sum value", "Aggregates columns to their sum value",
vec![Example { vec![Example {
description: "Sums all columns in a dataframe", description: "Sums all columns in a dataframe",
example: "[[a b]; [6 2] [1 4] [4 1]] | to-df | sum", example: "[[a b]; [6 2] [1 4] [4 1]] | into df | sum",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_int(11)],), Column::new("a".to_string(), vec![Value::test_int(11)],),
@ -182,7 +182,7 @@ lazy_command!(
"Aggregates columns to their mean value", "Aggregates columns to their mean value",
vec![Example { vec![Example {
description: "Mean value from columns in a dataframe", description: "Mean value from columns in a dataframe",
example: "[[a b]; [6 2] [4 2] [2 2]] | to-df | mean", example: "[[a b]; [6 2] [4 2] [2 2]] | into df | mean",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_float(4.0)],), Column::new("a".to_string(), vec![Value::test_float(4.0)],),
@ -204,7 +204,7 @@ lazy_command!(
"Aggregates columns to their median value", "Aggregates columns to their median value",
vec![Example { vec![Example {
description: "Median value from columns in a dataframe", description: "Median value from columns in a dataframe",
example: "[[a b]; [6 2] [4 2] [2 2]] | to-df | median", example: "[[a b]; [6 2] [4 2] [2 2]] | into df | median",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_float(4.0)],), Column::new("a".to_string(), vec![Value::test_float(4.0)],),
@ -226,7 +226,7 @@ lazy_command!(
"Aggregates columns to their std value", "Aggregates columns to their std value",
vec![Example { vec![Example {
description: "Std value from columns in a dataframe", description: "Std value from columns in a dataframe",
example: "[[a b]; [6 2] [4 2] [2 2]] | to-df | std", example: "[[a b]; [6 2] [4 2] [2 2]] | into df | std",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_float(2.0)],), Column::new("a".to_string(), vec![Value::test_float(2.0)],),
@ -248,7 +248,7 @@ lazy_command!(
"Aggregates columns to their var value", "Aggregates columns to their var value",
vec![Example { vec![Example {
description: "Var value from columns in a dataframe", description: "Var value from columns in a dataframe",
example: "[[a b]; [6 2] [4 2] [2 2]] | to-df | var", example: "[[a b]; [6 2] [4 2] [2 2]] | into df | var",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_float(4.0)],), Column::new("a".to_string(), vec![Value::test_float(4.0)],),

View file

@ -32,7 +32,7 @@ impl Command for LazyQuantile {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "quantile value from columns in a dataframe", description: "quantile value from columns in a dataframe",
example: "[[a b]; [6 2] [1 4] [4 1]] | to-df | quantile 0.5", example: "[[a b]; [6 2] [1 4] [4 1]] | into df | quantile 0.5",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new("a".to_string(), vec![Value::test_float(4.0)]), Column::new("a".to_string(), vec![Value::test_float(4.0)]),

View file

@ -33,7 +33,7 @@ impl Command for LazySelect {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Select a column from the dataframe", description: "Select a column from the dataframe",
example: "[[a b]; [6 2] [4 2] [2 2]] | to-df | select a", example: "[[a b]; [6 2] [4 2] [2 2]] | into df | select a",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"a".to_string(), "a".to_string(),

View file

@ -39,7 +39,7 @@ impl Command for LazySortBy {
vec![ vec![
Example { Example {
description: "Sort dataframe by one column", description: "Sort dataframe by one column",
example: "[[a b]; [6 2] [1 4] [4 1]] | to-df | sort-by a", example: "[[a b]; [6 2] [1 4] [4 1]] | into df | sort-by a",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(
@ -57,7 +57,8 @@ impl Command for LazySortBy {
}, },
Example { Example {
description: "Sort column using two columns", description: "Sort column using two columns",
example: "[[a b]; [6 2] [1 1] [1 4] [2 4]] | to-df | sort-by [a b] -r [false true]", example:
"[[a b]; [6 2] [1 1] [1 4] [2 4]] | into df | sort-by [a b] -r [false true]",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(

View file

@ -11,7 +11,7 @@ pub struct ToLazyFrame;
impl Command for ToLazyFrame { impl Command for ToLazyFrame {
fn name(&self) -> &str { fn name(&self) -> &str {
"to-lazy" "into lazy"
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
@ -25,7 +25,7 @@ impl Command for ToLazyFrame {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Takes a dictionary and creates a lazy dataframe", description: "Takes a dictionary and creates a lazy dataframe",
example: "[[a b];[1 2] [3 4]] | to-lazy", example: "[[a b];[1 2] [3 4]] | into lazy",
result: None, result: None,
}] }]
} }

View file

@ -26,7 +26,7 @@ impl Command for AllFalse {
vec![ vec![
Example { Example {
description: "Returns true if all values are false", description: "Returns true if all values are false",
example: "[false false false] | to-df | all-false", example: "[false false false] | into df | all-false",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"all_false".to_string(), "all_false".to_string(),
@ -38,7 +38,7 @@ impl Command for AllFalse {
}, },
Example { Example {
description: "Checks the result from a comparison", description: "Checks the result from a comparison",
example: r#"let s = ([5 6 2 10] | to-df); example: r#"let s = ([5 6 2 10] | into df);
let res = ($s > 9); let res = ($s > 9);
$res | all-false"#, $res | all-false"#,
result: Some( result: Some(

View file

@ -26,7 +26,7 @@ impl Command for AllTrue {
vec![ vec![
Example { Example {
description: "Returns true if all values are true", description: "Returns true if all values are true",
example: "[true true true] | to-df | all-true", example: "[true true true] | into df | all-true",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"all_true".to_string(), "all_true".to_string(),
@ -38,7 +38,7 @@ impl Command for AllTrue {
}, },
Example { Example {
description: "Checks the result from a comparison", description: "Checks the result from a comparison",
example: r#"let s = ([5 6 2 8] | to-df); example: r#"let s = ([5 6 2 8] | into df);
let res = ($s > 9); let res = ($s > 9);
$res | all-true"#, $res | all-true"#,
result: Some( result: Some(

View file

@ -26,7 +26,7 @@ impl Command for ArgMax {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Returns index for max value", description: "Returns index for max value",
example: "[1 3 2] | to-df | arg-max", example: "[1 3 2] | into df | arg-max",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"arg_max".to_string(), "arg_max".to_string(),

View file

@ -26,7 +26,7 @@ impl Command for ArgMin {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Returns index for min value", description: "Returns index for min value",
example: "[1 3 2] | to-df | arg-min", example: "[1 3 2] | into df | arg-min",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"arg_min".to_string(), "arg_min".to_string(),

View file

@ -62,7 +62,7 @@ impl Command for Cumulative {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Cumulative sum for a series", description: "Cumulative sum for a series",
example: "[1 2 3 4 5] | to-df | cumulative sum", example: "[1 2 3 4 5] | into df | cumulative sum",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0_cumulative_sum".to_string(), "0_cumulative_sum".to_string(),

View file

@ -37,7 +37,7 @@ impl Command for AsDate {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Converts string to date", description: "Converts string to date",
example: r#"["2021-12-30" "2021-12-31"] | to-df | as-datetime "%Y-%m-%d""#, example: r#"["2021-12-30" "2021-12-31"] | into df | as-datetime "%Y-%m-%d""#,
result: None, result: None,
}] }]
} }

View file

@ -46,7 +46,7 @@ impl Command for AsDateTime {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Converts string to datetime", description: "Converts string to datetime",
example: r#"["2021-12-30 00:00:00" "2021-12-31 00:00:00"] | to-df | as-datetime "%Y-%m-%d %H:%M:%S""#, example: r#"["2021-12-30 00:00:00" "2021-12-31 00:00:00"] | into df | as-datetime "%Y-%m-%d %H:%M:%S""#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"datetime".to_string(), "datetime".to_string(),

View file

@ -27,7 +27,7 @@ impl Command for GetDay {
vec![Example { vec![Example {
description: "Returns day from a date", description: "Returns day from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-day"#, $df | get-day"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -27,7 +27,7 @@ impl Command for GetHour {
vec![Example { vec![Example {
description: "Returns hour from a date", description: "Returns hour from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-hour"#, $df | get-hour"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -27,7 +27,7 @@ impl Command for GetMinute {
vec![Example { vec![Example {
description: "Returns minute from a date", description: "Returns minute from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-minute"#, $df | get-minute"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -27,7 +27,7 @@ impl Command for GetMonth {
vec![Example { vec![Example {
description: "Returns month from a date", description: "Returns month from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-month"#, $df | get-month"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -27,7 +27,7 @@ impl Command for GetNanosecond {
vec![Example { vec![Example {
description: "Returns nanosecond from a date", description: "Returns nanosecond from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-nanosecond"#, $df | get-nanosecond"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -27,7 +27,7 @@ impl Command for GetOrdinal {
vec![Example { vec![Example {
description: "Returns ordinal from a date", description: "Returns ordinal from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-ordinal"#, $df | get-ordinal"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -27,7 +27,7 @@ impl Command for GetSecond {
vec![Example { vec![Example {
description: "Returns second from a date", description: "Returns second from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-second"#, $df | get-second"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -27,7 +27,7 @@ impl Command for GetWeek {
vec![Example { vec![Example {
description: "Returns week from a date", description: "Returns week from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-week"#, $df | get-week"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -27,7 +27,7 @@ impl Command for GetWeekDay {
vec![Example { vec![Example {
description: "Returns weekday from a date", description: "Returns weekday from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-weekday"#, $df | get-weekday"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -27,7 +27,7 @@ impl Command for GetYear {
vec![Example { vec![Example {
description: "Returns year from a date", description: "Returns year from a date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | get-year"#, $df | get-year"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -30,7 +30,7 @@ impl Command for ArgSort {
vec![ vec![
Example { Example {
description: "Returns indexes for a sorted series", description: "Returns indexes for a sorted series",
example: "[1 2 2 3 3] | to-df | arg-sort", example: "[1 2 2 3 3] | into df | arg-sort",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"arg_sort".to_string(), "arg_sort".to_string(),
@ -48,7 +48,7 @@ impl Command for ArgSort {
}, },
Example { Example {
description: "Returns indexes for a sorted series", description: "Returns indexes for a sorted series",
example: "[1 2 2 3 3] | to-df | arg-sort -r", example: "[1 2 2 3 3] | into df | arg-sort -r",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"arg_sort".to_string(), "arg_sort".to_string(),

View file

@ -26,7 +26,7 @@ impl Command for ArgTrue {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Returns indexes where values are true", description: "Returns indexes where values are true",
example: "[false true false] | to-df | arg-true", example: "[false true false] | into df | arg-true",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"arg_true".to_string(), "arg_true".to_string(),

View file

@ -26,7 +26,7 @@ impl Command for ArgUnique {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Returns indexes for unique values", description: "Returns indexes for unique values",
example: "[1 2 2 3 3] | to-df | arg-unique", example: "[1 2 2 3 3] | into df | arg-unique",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"arg_unique".to_string(), "arg_unique".to_string(),

View file

@ -35,8 +35,8 @@ impl Command for SetWithIndex {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Set value in selected rows from series", description: "Set value in selected rows from series",
example: r#"let series = ([4 1 5 2 4 3] | to-df); example: r#"let series = ([4 1 5 2 4 3] | into df);
let indices = ([0 2] | to-df); let indices = ([0 2] | into df);
$series | set-with-idx 6 -i $indices"#, $series | set-with-idx 6 -i $indices"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -26,7 +26,7 @@ impl Command for IsDuplicated {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Create mask indicating duplicated values", description: "Create mask indicating duplicated values",
example: "[5 6 6 6 8 8 8] | to-df | is-duplicated", example: "[5 6 6 6 8 8 8] | into df | is-duplicated",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"is_duplicated".to_string(), "is_duplicated".to_string(),

View file

@ -29,8 +29,8 @@ impl Command for IsIn {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Checks if elements from a series are contained in right series", description: "Checks if elements from a series are contained in right series",
example: r#"let other = ([1 3 6] | to-df); example: r#"let other = ([1 3 6] | into df);
[5 6 6 6 8 8 8] | to-df | is-in $other"#, [5 6 6 6 8 8 8] | into df | is-in $other"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"is_in".to_string(), "is_in".to_string(),

View file

@ -25,7 +25,7 @@ impl Command for IsNotNull {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Create mask where values are not null", description: "Create mask where values are not null",
example: r#"let s = ([5 6 0 8] | to-df); example: r#"let s = ([5 6 0 8] | into df);
let res = ($s / $s); let res = ($s / $s);
$res | is-not-null"#, $res | is-not-null"#,
result: Some( result: Some(

View file

@ -25,7 +25,7 @@ impl Command for IsNull {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Create mask where values are null", description: "Create mask where values are null",
example: r#"let s = ([5 6 0 8] | to-df); example: r#"let s = ([5 6 0 8] | into df);
let res = ($s / $s); let res = ($s / $s);
$res | is-null"#, $res | is-null"#,
result: Some( result: Some(

View file

@ -26,7 +26,7 @@ impl Command for IsUnique {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Create mask indicating unique values", description: "Create mask indicating unique values",
example: "[5 6 6 6 8 8 8] | to-df | is-unique", example: "[5 6 6 6 8 8 8] | into df | is-unique",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"is_unique".to_string(), "is_unique".to_string(),

View file

@ -27,7 +27,7 @@ impl Command for NotSeries {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Inverts boolean mask", description: "Inverts boolean mask",
example: "[true false true] | to-df | df-not", example: "[true false true] | into df | df-not",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -35,7 +35,7 @@ impl Command for SetSeries {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Shifts the values by a given period", description: "Shifts the values by a given period",
example: r#"let s = ([1 2 2 3 3] | to-df | shift 2); example: r#"let s = ([1 2 2 3 3] | into df | shift 2);
let mask = ($s | is-null); let mask = ($s | is-null);
$s | set 0 --mask $mask"#, $s | set 0 --mask $mask"#,
result: Some( result: Some(

View file

@ -25,7 +25,7 @@ impl Command for NNull {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Counts null values", description: "Counts null values",
example: r#"let s = ([1 1 0 0 3 3 4] | to-df); example: r#"let s = ([1 1 0 0 3 3 4] | into df);
($s / $s) | count-null"#, ($s / $s) | count-null"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -24,7 +24,7 @@ impl Command for NUnique {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Counts unique values", description: "Counts unique values",
example: "[1 1 2 2 3 3 4] | to-df | n-unique", example: "[1 1 2 2 3 3 4] | into df | n-unique",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"count_unique".to_string(), "count_unique".to_string(),

View file

@ -66,7 +66,7 @@ impl Command for Rolling {
vec![ vec![
Example { Example {
description: "Rolling sum for a series", description: "Rolling sum for a series",
example: "[1 2 3 4 5] | to-df | rolling sum 2 | drop-nulls", example: "[1 2 3 4 5] | into df | rolling sum 2 | drop-nulls",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0_rolling_sum".to_string(), "0_rolling_sum".to_string(),
@ -83,7 +83,7 @@ impl Command for Rolling {
}, },
Example { Example {
description: "Rolling max for a series", description: "Rolling max for a series",
example: "[1 2 3 4 5] | to-df | rolling max 2 | drop-nulls", example: "[1 2 3 4 5] | into df | rolling max 2 | drop-nulls",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0_rolling_max".to_string(), "0_rolling_max".to_string(),

View file

@ -36,7 +36,7 @@ impl Command for Shift {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Shifts the values by a given period", description: "Shifts the values by a given period",
example: "[1 2 2 3 3] | to-df | shift 2 | drop-nulls", example: "[1 2 2 3 3] | into df | shift 2 | drop-nulls",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -33,8 +33,8 @@ impl Command for Concatenate {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Concatenate string", description: "Concatenate string",
example: r#"let other = ([za xs cd] | to-df); example: r#"let other = ([za xs cd] | into df);
[abc abc abc] | to-df | concatenate $other"#, [abc abc abc] | into df | concatenate $other"#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -33,7 +33,7 @@ impl Command for Contains {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Returns boolean indicating if pattern was found", description: "Returns boolean indicating if pattern was found",
example: "[abc acb acb] | to-df | contains ab", example: "[abc acb acb] | into df | contains ab",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -40,7 +40,7 @@ impl Command for Replace {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Replaces string", description: "Replaces string",
example: "[abc abc abc] | to-df | replace -p ab -r AB", example: "[abc abc abc] | into df | replace -p ab -r AB",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -40,7 +40,7 @@ impl Command for ReplaceAll {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Replaces string", description: "Replaces string",
example: "[abac abac abac] | to-df | replace-all -p a -r A", example: "[abac abac abac] | into df | replace-all -p a -r A",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -26,7 +26,7 @@ impl Command for StrLengths {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Returns string lengths", description: "Returns string lengths",
example: "[a ab abc] | to-df | str-lengths", example: "[a ab abc] | into df | str-lengths",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -30,7 +30,7 @@ impl Command for StrSlice {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Creates slices from the strings", description: "Creates slices from the strings",
example: "[abcded abc321 abc123] | to-df | str-slice 1 -l 2", example: "[abcded abc321 abc123] | into df | str-slice 1 -l 2",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -30,7 +30,7 @@ impl Command for StrFTime {
vec![Example { vec![Example {
description: "Formats date", description: "Formats date",
example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC'); example: r#"let dt = ('2020-08-04T16:39:18+00:00' | into datetime -z 'UTC');
let df = ([$dt $dt] | to-df); let df = ([$dt $dt] | into df);
$df | strftime "%Y/%m/%d""#, $df | strftime "%Y/%m/%d""#,
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(

View file

@ -12,7 +12,7 @@ pub struct ToLowerCase;
impl Command for ToLowerCase { impl Command for ToLowerCase {
fn name(&self) -> &str { fn name(&self) -> &str {
"to-lowercase" "lowercase"
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
@ -26,7 +26,7 @@ impl Command for ToLowerCase {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Modifies strings to lowercase", description: "Modifies strings to lowercase",
example: "[Abc aBc abC] | to-df | to-lowercase", example: "[Abc aBc abC] | into df | lowercase",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -12,7 +12,7 @@ pub struct ToUpperCase;
impl Command for ToUpperCase { impl Command for ToUpperCase {
fn name(&self) -> &str { fn name(&self) -> &str {
"to-uppercase" "uppercase"
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
@ -26,7 +26,7 @@ impl Command for ToUpperCase {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Modifies strings to uppercase", description: "Modifies strings to uppercase",
example: "[Abc aBc abC] | to-df | to-uppercase", example: "[Abc aBc abC] | into df | uppercase",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -47,7 +47,7 @@ impl Command for Unique {
vec![ vec![
Example { Example {
description: "Returns unique values from a series", description: "Returns unique values from a series",
example: "[2 2 2 2 2] | to-df | unique", example: "[2 2 2 2 2] | into df | unique",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![Column::new( NuDataFrame::try_from_columns(vec![Column::new(
"0".to_string(), "0".to_string(),

View file

@ -25,7 +25,7 @@ impl Command for ValueCount {
fn examples(&self) -> Vec<Example> { fn examples(&self) -> Vec<Example> {
vec![Example { vec![Example {
description: "Calculates value counts", description: "Calculates value counts",
example: "[5 5 5 5 6 6] | to-df | value-counts", example: "[5 5 5 5 6 6] | into df | value-counts",
result: Some( result: Some(
NuDataFrame::try_from_columns(vec![ NuDataFrame::try_from_columns(vec![
Column::new( Column::new(