From 2df04e04ecdf42386836b373b317326879ea512f Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:38:34 +0100 Subject: [PATCH] more reordering and fixup rust test --- crates/polars/tests/it/core/pivot.rs | 2 +- docs/src/python/user-guide/transformations/pivot.py | 2 +- py-polars/polars/dataframe/frame.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/polars/tests/it/core/pivot.rs b/crates/polars/tests/it/core/pivot.rs index fc0e8481aa8f..144c3291a54e 100644 --- a/crates/polars/tests/it/core/pivot.rs +++ b/crates/polars/tests/it/core/pivot.rs @@ -120,8 +120,8 @@ fn test_pivot_old() { ); let pvt = pivot( &df, - ["index"], ["columns"], + ["index"], Some(["values"]), false, Some(PivotAgg::Count), diff --git a/docs/src/python/user-guide/transformations/pivot.py b/docs/src/python/user-guide/transformations/pivot.py index a51db55bbdf4..95354072d24e 100644 --- a/docs/src/python/user-guide/transformations/pivot.py +++ b/docs/src/python/user-guide/transformations/pivot.py @@ -15,7 +15,7 @@ # --8<-- [end:df] # --8<-- [start:eager] -out = df.pivot(index="foo", on="bar", values="N", aggregate_function="first") +out = df.pivot("bar", index="foo", values="N", aggregate_function="first") print(out) # --8<-- [end:eager] diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index 9cc63ceb9590..357731cdf952 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -7609,10 +7609,10 @@ def pivot( on Name of the column(s) whose values will be used as the header of the output DataFrame. - values - Column values to aggregate. If None, all remaining columns will be used. index One or multiple keys to group by. + values + Column values to aggregate. If None, all remaining columns will be used. aggregate_function Choose from: @@ -7644,7 +7644,7 @@ def pivot( ... "baz": [1, 2, 3, 4, 5, 6], ... } ... ) - >>> df.pivot(index="foo", on="bar", values="baz", aggregate_function="sum") + >>> df.pivot("bar", index="foo", values="baz", aggregate_function="sum") shape: (2, 3) ┌─────┬─────┬─────┐ │ foo ┆ y ┆ x │