formatting
This commit is contained in:
parent
074ec52754
commit
a467939f67
|
@ -1,7 +1,7 @@
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span,
|
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, SyntaxShape, Type,
|
||||||
SyntaxShape, Type, Value,
|
Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use polars_ops::pivot::pivot;
|
use polars_ops::pivot::pivot;
|
||||||
|
@ -73,7 +73,9 @@ impl PluginCommand for PivotDF {
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
match PolarsPluginObject::try_from_pipeline(plugin, input, call.head)? {
|
match PolarsPluginObject::try_from_pipeline(plugin, input, call.head)? {
|
||||||
PolarsPluginObject::NuDataFrame(df) => command_eager(plugin, engine, call, df),
|
PolarsPluginObject::NuDataFrame(df) => command_eager(plugin, engine, call, df),
|
||||||
PolarsPluginObject::NuLazyFrame(lazy) => command_eager(plugin, engine, call, lazy.collect(call.head)?),
|
PolarsPluginObject::NuLazyFrame(lazy) => {
|
||||||
|
command_eager(plugin, engine, call, lazy.collect(call.head)?)
|
||||||
|
}
|
||||||
_ => Err(ShellError::GenericError {
|
_ => Err(ShellError::GenericError {
|
||||||
error: "Must be a dataframe or lazy dataframe".into(),
|
error: "Must be a dataframe or lazy dataframe".into(),
|
||||||
msg: "".into(),
|
msg: "".into(),
|
||||||
|
@ -106,7 +108,15 @@ fn command_eager(
|
||||||
|
|
||||||
let polars_df = df.to_polars();
|
let polars_df = df.to_polars();
|
||||||
// todo add other args
|
// todo add other args
|
||||||
let pivoted = pivot(&polars_df, &on_col_string, Some(&index_col_string), Some(&val_col_string), false, None, None)
|
let pivoted = pivot(
|
||||||
|
&polars_df,
|
||||||
|
&on_col_string,
|
||||||
|
Some(&index_col_string),
|
||||||
|
Some(&val_col_string),
|
||||||
|
false,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
.map_err(|e| ShellError::GenericError {
|
.map_err(|e| ShellError::GenericError {
|
||||||
error: format!("Pivot error: {e}"),
|
error: format!("Pivot error: {e}"),
|
||||||
msg: "".into(),
|
msg: "".into(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user