From 8766aa3f3b2f672090a8c86c344172aab90681a8 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:19:31 +0100 Subject: [PATCH] more rust alignment --- crates/polars-core/src/frame/explode.rs | 8 ++++---- crates/polars-lazy/src/tests/queries.rs | 2 +- crates/polars-ops/src/frame/pivot/mod.rs | 8 ++++---- py-polars/src/dataframe/general.rs | 2 +- py-polars/src/lazyframe/mod.rs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/polars-core/src/frame/explode.rs b/crates/polars-core/src/frame/explode.rs index c7ed14eca344..a405067d834c 100644 --- a/crates/polars-core/src/frame/explode.rs +++ b/crates/polars-core/src/frame/explode.rs @@ -24,8 +24,8 @@ fn get_exploded(series: &Series) -> PolarsResult<(Series, OffsetsBuffer)> { #[derive(Clone, Default, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde-lazy", derive(Serialize, Deserialize))] pub struct UnpivotArgs { - pub index: Vec, pub on: Vec, + pub index: Vec, pub variable_name: Option, pub value_name: Option, /// Whether the unpivot may be done @@ -247,8 +247,8 @@ impl DataFrame { let index = index.into_vec(); let on = on.into_vec(); self.unpivot2(UnpivotArgs { - index, on, + index, ..Default::default() }) } @@ -448,8 +448,8 @@ mod test { ); let args = UnpivotArgs { - index: vec![], on: vec![], + index: vec![], ..Default::default() }; @@ -464,8 +464,8 @@ mod test { ); let args = UnpivotArgs { - index: vec!["A".into()], on: vec![], + index: vec!["A".into()], ..Default::default() }; diff --git a/crates/polars-lazy/src/tests/queries.rs b/crates/polars-lazy/src/tests/queries.rs index 690dc6f57ea9..ade6df69c57e 100644 --- a/crates/polars-lazy/src/tests/queries.rs +++ b/crates/polars-lazy/src/tests/queries.rs @@ -50,8 +50,8 @@ fn test_lazy_unpivot() { let df = get_df(); let args = UnpivotArgs { - index: vec!["petal_width".into(), "petal_length".into()], on: vec!["sepal_length".into(), "sepal_width".into()], + index: vec!["petal_width".into(), "petal_length".into()], ..Default::default() }; diff --git a/crates/polars-ops/src/frame/pivot/mod.rs b/crates/polars-ops/src/frame/pivot/mod.rs index 194f3a2c5d69..11a2d0b64248 100644 --- a/crates/polars-ops/src/frame/pivot/mod.rs +++ b/crates/polars-ops/src/frame/pivot/mod.rs @@ -110,8 +110,8 @@ where let values = get_values_columns(pivot_df, &index, &on, values); pivot_impl( pivot_df, - &index, &on, + &index, &values, agg_fn, sort_columns, @@ -153,8 +153,8 @@ where let values = get_values_columns(pivot_df, &index, &on, values); pivot_impl( pivot_df, - &index, &on, + &index, &values, agg_fn, sort_columns, @@ -192,11 +192,11 @@ where fn pivot_impl( pivot_df: &DataFrame, // keys of the first group_by operation + on: &[String], + // these columns will be aggregated in the nested group_by index: &[String], // these columns will be used for a nested group_by // the rows of this nested group_by will be pivoted as header column values - on: &[String], - // these columns will be aggregated in the nested group_by values: &[String], // aggregation function agg_fn: Option, diff --git a/py-polars/src/dataframe/general.rs b/py-polars/src/dataframe/general.rs index 421afe0c5995..40978fe7427c 100644 --- a/py-polars/src/dataframe/general.rs +++ b/py-polars/src/dataframe/general.rs @@ -405,8 +405,8 @@ impl PyDataFrame { variable_name: Option<&str>, ) -> PyResult { let args = UnpivotArgs { - index: strings_to_smartstrings(index), on: strings_to_smartstrings(on), + index: strings_to_smartstrings(index), value_name: value_name.map(|s| s.into()), variable_name: variable_name.map(|s| s.into()), streamable: false, diff --git a/py-polars/src/lazyframe/mod.rs b/py-polars/src/lazyframe/mod.rs index 277a2c1980a7..ce18a4ea2f35 100644 --- a/py-polars/src/lazyframe/mod.rs +++ b/py-polars/src/lazyframe/mod.rs @@ -1121,8 +1121,8 @@ impl PyLazyFrame { streamable: bool, ) -> Self { let args = UnpivotArgs { - index: strings_to_smartstrings(index), on: strings_to_smartstrings(on), + index: strings_to_smartstrings(index), value_name: value_name.map(|s| s.into()), variable_name: variable_name.map(|s| s.into()), streamable,