mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 01:43:47 +01:00
add tests to polars unique
(#12683)
# Description I would like to help with `polars` plugin development and add tests to all the `polars` command's existing params. Since I have never written any lines of Rust, even though the task of creating tests is relatively simple, I would like to ask for feedback to ensure I did everything correctly here.
This commit is contained in:
parent
76d1d70e83
commit
884d5312bb
@ -66,6 +66,59 @@ impl PluginCommand for Unique {
|
||||
.into_value(Span::test_data()),
|
||||
),
|
||||
},
|
||||
Example {
|
||||
description: "Returns unique values in a subset of lazyframe columns",
|
||||
example: "[[a b c]; [1 2 1] [2 2 2] [3 2 1]] | polars into-lazy | polars unique --subset [b c] | polars collect",
|
||||
result: Some(
|
||||
NuDataFrame::try_from_columns(
|
||||
vec![
|
||||
Column::new(
|
||||
"a".to_string(),
|
||||
vec![Value::test_int(1), Value::test_int(2)]
|
||||
),
|
||||
Column::new(
|
||||
"b".to_string(),
|
||||
vec![Value::test_int(2), Value::test_int(2)]
|
||||
),
|
||||
Column::new(
|
||||
"c".to_string(),
|
||||
vec![Value::test_int(1), Value::test_int(2)]
|
||||
)
|
||||
],
|
||||
None,
|
||||
)
|
||||
.expect("simple df for test should not fail")
|
||||
.into_value(Span::test_data()),
|
||||
),
|
||||
},
|
||||
Example {
|
||||
description: "Returns unique values in a subset of lazyframe columns",
|
||||
example: r#"[[a b c]; [1 2 1] [2 2 2] [3 2 1]]
|
||||
| polars into-lazy
|
||||
| polars unique --subset [b c] --last
|
||||
| polars collect"#,
|
||||
result: Some(
|
||||
NuDataFrame::try_from_columns(
|
||||
vec![
|
||||
Column::new(
|
||||
"a".to_string(),
|
||||
vec![Value::test_int(2), Value::test_int(3)]
|
||||
),
|
||||
Column::new(
|
||||
"b".to_string(),
|
||||
vec![Value::test_int(2), Value::test_int(2)]
|
||||
),
|
||||
Column::new(
|
||||
"c".to_string(),
|
||||
vec![Value::test_int(2), Value::test_int(1)]
|
||||
)
|
||||
],
|
||||
None,
|
||||
)
|
||||
.expect("simple df for test should not fail")
|
||||
.into_value(Span::test_data()),
|
||||
),
|
||||
},
|
||||
Example {
|
||||
description: "Creates a is unique expression from a column",
|
||||
example: "col a | unique",
|
||||
|
Loading…
Reference in New Issue
Block a user