diff --git a/narwhals/pandas_like/group_by.py b/narwhals/pandas_like/group_by.py index 1fe734197..983c9f5da 100644 --- a/narwhals/pandas_like/group_by.py +++ b/narwhals/pandas_like/group_by.py @@ -8,6 +8,8 @@ from typing import Callable from typing import Iterable +from packaging.version import parse + from narwhals.pandas_like.utils import dataframe_from_dict from narwhals.pandas_like.utils import evaluate_simple_aggregation from narwhals.pandas_like.utils import horizontal_concat @@ -122,7 +124,10 @@ def func(df: Any) -> Any: out_names.append(result_keys.name) return pd.Series(out_group, index=out_names) - result_complex = grouped.apply(func, include_groups=False) + if parse(pd.__version__) < parse("2.2.0"): + result_complex = grouped.apply(func) + else: + result_complex = grouped.apply(func, include_groups=False) if result_simple is not None: result = pd.concat( diff --git a/tests/test_common.py b/tests/test_common.py index 54201e780..4b298d809 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -3,7 +3,6 @@ import warnings from typing import Any -import modin.pandas as mpd import numpy as np import pandas as pd import polars as pl @@ -17,8 +16,8 @@ df_lazy = pl.LazyFrame({"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]}) with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=UserWarning) - df_mpd = mpd.DataFrame( - mpd.DataFrame({"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]}) + df_mpd = pd.DataFrame( + pd.DataFrame({"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]}) ) @@ -234,6 +233,9 @@ def test_convert_pandas(df_raw: Any) -> None: @pytest.mark.parametrize("df_raw", [df_polars, df_pandas, df_mpd]) +@pytest.mark.filterwarnings( + r"ignore:np\.find_common_type is deprecated\.:DeprecationWarning" +) def test_convert_numpy(df_raw: Any) -> None: result = nw.DataFrame(df_raw).to_numpy() expected = np.array([[1, 3, 2], [4, 4, 6], [7.0, 8, 9]]).T