diff --git a/python/cudf/cudf/core/groupby/groupby.py b/python/cudf/cudf/core/groupby/groupby.py index 1f08abdc7fc..78593f20421 100644 --- a/python/cudf/cudf/core/groupby/groupby.py +++ b/python/cudf/cudf/core/groupby/groupby.py @@ -2640,6 +2640,8 @@ def agg(self, func): return result + aggregate = agg + def apply(self, func, *args): result = super().apply(func, *args) diff --git a/python/cudf/cudf/tests/groupby/test_agg.py b/python/cudf/cudf/tests/groupby/test_agg.py index 7919ee4a9f1..f8847f02d5a 100644 --- a/python/cudf/cudf/tests/groupby/test_agg.py +++ b/python/cudf/cudf/tests/groupby/test_agg.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. import numpy as np import pytest @@ -16,3 +16,13 @@ def test_agg_count_dtype(empty): df = df.iloc[:0] result = df.groupby("a").agg({"c": "count"}) assert result["c"].dtype == np.dtype("int64") + + +@pytest.mark.parametrize("attr", ["agg", "aggregate"]) +def test_series_agg(attr): + df = cudf.DataFrame({"a": [1, 2, 1, 2], "b": [0, 0, 0, 0]}) + pdf = df.to_pandas() + agg = getattr(df.groupby("a")["a"], attr)("count") + pd_agg = getattr(pdf.groupby(["a"])["a"], attr)("count") + + assert agg.ndim == pd_agg.ndim