Renaming melt to unvpivot to match polars change
This commit is contained in:
parent
a7e6f8a0eb
commit
f3e36ef7f5
|
@ -9,7 +9,7 @@ mod filter_with;
|
||||||
mod first;
|
mod first;
|
||||||
mod get;
|
mod get;
|
||||||
mod last;
|
mod last;
|
||||||
mod melt;
|
mod unpivot;
|
||||||
mod open;
|
mod open;
|
||||||
mod query_df;
|
mod query_df;
|
||||||
mod rename;
|
mod rename;
|
||||||
|
@ -44,7 +44,7 @@ pub use filter_with::FilterWith;
|
||||||
pub use first::FirstDF;
|
pub use first::FirstDF;
|
||||||
pub use get::GetDF;
|
pub use get::GetDF;
|
||||||
pub use last::LastDF;
|
pub use last::LastDF;
|
||||||
pub use melt::MeltDF;
|
pub use unpivot::UnpivotDF;
|
||||||
use nu_plugin::PluginCommand;
|
use nu_plugin::PluginCommand;
|
||||||
pub use query_df::QueryDf;
|
pub use query_df::QueryDf;
|
||||||
pub use rename::RenameDF;
|
pub use rename::RenameDF;
|
||||||
|
@ -76,7 +76,7 @@ pub(crate) fn eager_commands() -> Vec<Box<dyn PluginCommand<Plugin = PolarsPlugi
|
||||||
Box::new(FilterWith),
|
Box::new(FilterWith),
|
||||||
Box::new(GetDF),
|
Box::new(GetDF),
|
||||||
Box::new(OpenDataFrame),
|
Box::new(OpenDataFrame),
|
||||||
Box::new(MeltDF),
|
Box::new(UnpivotDF),
|
||||||
Box::new(Summary),
|
Box::new(Summary),
|
||||||
Box::new(FirstDF),
|
Box::new(FirstDF),
|
||||||
Box::new(LastDF),
|
Box::new(LastDF),
|
||||||
|
|
|
@ -11,13 +11,13 @@ use crate::{
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct MeltDF;
|
pub struct UnpivotDF;
|
||||||
|
|
||||||
impl PluginCommand for MeltDF {
|
impl PluginCommand for UnpivotDF {
|
||||||
type Plugin = PolarsPlugin;
|
type Plugin = PolarsPlugin;
|
||||||
|
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"polars melt"
|
"polars unpivot"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
|
@ -29,7 +29,7 @@ impl PluginCommand for MeltDF {
|
||||||
.required_named(
|
.required_named(
|
||||||
"columns",
|
"columns",
|
||||||
SyntaxShape::Table(vec![]),
|
SyntaxShape::Table(vec![]),
|
||||||
"column names for melting",
|
"column names for unpivoting",
|
||||||
Some('c'),
|
Some('c'),
|
||||||
)
|
)
|
||||||
.required_named(
|
.required_named(
|
||||||
|
@ -59,9 +59,9 @@ impl PluginCommand for MeltDF {
|
||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![Example {
|
||||||
description: "melt dataframe",
|
description: "unpivot dataframe",
|
||||||
example:
|
example:
|
||||||
"[[a b c d]; [x 1 4 a] [y 2 5 b] [z 3 6 c]] | polars into-df | polars melt -c [b c] -v [a d]",
|
"[[a b c d]; [x 1 4 a] [y 2 5 b] [z 3 6 c]] | polars into-df | polars unpivot -c [b c] -v [a d]",
|
||||||
result: Some(
|
result: Some(
|
||||||
NuDataFrame::try_from_columns(vec![
|
NuDataFrame::try_from_columns(vec![
|
||||||
Column::new(
|
Column::new(
|
||||||
|
@ -148,9 +148,9 @@ fn command(
|
||||||
|
|
||||||
let mut res = df
|
let mut res = df
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.melt(&id_col_string, &val_col_string)
|
.unpivot(&id_col_string, &val_col_string)
|
||||||
.map_err(|e| ShellError::GenericError {
|
.map_err(|e| ShellError::GenericError {
|
||||||
error: "Error calculating melt".into(),
|
error: "Error calculating unpivot".into(),
|
||||||
msg: e.to_string(),
|
msg: e.to_string(),
|
||||||
span: Some(call.head),
|
span: Some(call.head),
|
||||||
help: None,
|
help: None,
|
||||||
|
@ -248,6 +248,6 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_examples() -> Result<(), ShellError> {
|
fn test_examples() -> Result<(), ShellError> {
|
||||||
test_polars_plugin_command(&MeltDF)
|
test_polars_plugin_command(&UnpivotDF)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user