From 4ff71b2565b982efdcce92ccbdde81c6f71b73a4 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Tue, 19 Mar 2024 21:44:39 +0000 Subject: [PATCH] modin can use fastpath too --- narwhals/pandas_like/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/narwhals/pandas_like/utils.py b/narwhals/pandas_like/utils.py index bdfbb5955..9486e94fb 100644 --- a/narwhals/pandas_like/utils.py +++ b/narwhals/pandas_like/utils.py @@ -234,7 +234,11 @@ def evaluate_simple_aggregation(expr: PandasExpr, grouped: Any, keys: list[str]) if expr._depth == 0: # e.g. agg(pl.len()) df = getattr(grouped, expr._function_name.replace("len", "size"))() - df = df.drop(columns=keys) if len(df.shape) > 1 else df.to_frame("size") + df = ( + df.drop(columns=keys) + if len(df.shape) > 1 + else df.reset_index(drop=True).to_frame("size") + ) return df.rename(columns={"size": expr._output_names[0]}) # type: ignore[index] if expr._root_names is None or expr._output_names is None: msg = "Expected expr to have root_names and output_names set, but they are None. Please report a bug."