From c4fcac04672b492fd261ba35ade8b1dbecd6f701 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Sat, 21 Dec 2024 14:32:20 +0000 Subject: [PATCH] clean --- narwhals/_pandas_like/dataframe.py | 7 ++----- narwhals/_pandas_like/utils.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/narwhals/_pandas_like/dataframe.py b/narwhals/_pandas_like/dataframe.py index a011781d9..d9035e4d4 100644 --- a/narwhals/_pandas_like/dataframe.py +++ b/narwhals/_pandas_like/dataframe.py @@ -866,7 +866,6 @@ def pivot( if aggregate_function is None: result = frame.pivot(columns=on, index=index, values=values_) - elif aggregate_function == "len": result = ( frame.groupby([*on, *index]) # type: ignore[misc] @@ -882,11 +881,9 @@ def pivot( columns=on, aggregate_function=aggregate_function, ) + # Put columns in the right order - if ( - sort_columns - and self._implementation is Implementation.CUDF # pragma: no cover - ): + if sort_columns and self._implementation is Implementation.CUDF: uniques = { col: sorted(self._native_frame[col].unique().to_arrow().to_pylist()) for col in on diff --git a/narwhals/_pandas_like/utils.py b/narwhals/_pandas_like/utils.py index 89a030981..f4f6962e0 100644 --- a/narwhals/_pandas_like/utils.py +++ b/narwhals/_pandas_like/utils.py @@ -781,7 +781,7 @@ def pivot_table( aggregate_function: str | None, ) -> Any: dtypes = import_dtypes_module(df._version) - if df._implementation is Implementation.CUDF: # pragma: no cover + if df._implementation is Implementation.CUDF: if any(x == dtypes.Categorical for x in df.schema.values()): msg = "`pivot` with Categoricals is not implemented for cuDF backend" raise NotImplementedError(msg)