Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Dec 21, 2024
1 parent 248df6a commit c4fcac0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions narwhals/_pandas_like/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion narwhals/_pandas_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c4fcac0

Please sign in to comment.