Skip to content

Commit

Permalink
record "len" as simple aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Mar 19, 2024
1 parent 67b7df0 commit cf9e23d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions narwhals/pandas_like/group_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def agg_pandas(
simple_aggs = []
complex_aggs = []
for expr in exprs:
if is_simple_aggregation(expr, implementation="pandas"):
if is_simple_aggregation(expr):
simple_aggs.append(expr)
else:
complex_aggs.append(expr)
Expand Down Expand Up @@ -173,7 +173,7 @@ def agg_generic( # noqa: PLR0913
dfs: list[Any] = []
to_remove: list[int] = []
for i, expr in enumerate(exprs):
if is_simple_aggregation(expr, implementation):
if is_simple_aggregation(expr):
dfs.append(evaluate_simple_aggregation(expr, grouped))
to_remove.append(i)
exprs = [expr for i, expr in enumerate(exprs) if i not in to_remove]
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 @@ -232,7 +232,7 @@ def evaluate_simple_aggregation(expr: PandasExpr, grouped: Any) -> Any:
Returns naive DataFrame.
"""
if expr._depth == 0:
return grouped.size()["size"].rename(expr._output_names[0])
return grouped.size()["size"].rename(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."
raise AssertionError(msg)
Expand Down

0 comments on commit cf9e23d

Please sign in to comment.