Skip to content

Commit

Permalink
versions compat
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Jan 26, 2025
1 parent 7753490 commit 7bca332
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion narwhals/_pandas_like/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,15 @@ def func(df: PandasLikeDataFrame) -> list[PandasLikeSeries]:
kwargs = {"skipna": True}

res_native = getattr(
df._native_frame.groupby(list(keys), as_index=False)[
df._native_frame.groupby([df._native_frame[key] for key in keys])[
list(output_names)
],
MANY_TO_MANY_AGG_FUNCTIONS_TO_PANDAS_EQUIVALENT[function_name],
)(**kwargs)

# how else to do this...
#

result_frame = df._from_native_frame(
rename(
res_native,
Expand Down
4 changes: 3 additions & 1 deletion tests/expr_and_series/over_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ def test_over_anonymous_cumulative(constructor_eager: ConstructorEager) -> None:
if df.implementation.is_pyarrow()
else pytest.raises(KeyError) # type: ignore[arg-type]
if df.implementation.is_modin()
or (df.implementation.is_pandas() and PANDAS_VERSION < (1, 4))
# TODO(unassigned): bug in old pandas + modin.
# df.groupby('a')[['a', 'b']].cum_sum() excludes `'a'` from result
else does_not_raise()
)
# TODO(unassigned): why does modin raise here? bug in modin?
with context:
result = df.with_columns(
nw.all().cum_sum().over("a").name.suffix("_cum_sum")
Expand Down

0 comments on commit 7bca332

Please sign in to comment.