diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index f076f8d79f104..5ba382bf66bb7 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -32,6 +32,7 @@ Appender, Substitution, doc, + set_module, ) from pandas.util._exceptions import find_stack_level @@ -108,6 +109,7 @@ ScalarResult = TypeVar("ScalarResult") +@set_module("pandas") class NamedAgg(NamedTuple): """ Helper for column specific aggregation with control over output column names. @@ -142,6 +144,7 @@ class NamedAgg(NamedTuple): aggfunc: AggScalar +@set_module("pandas.api.typing") class SeriesGroupBy(GroupBy[Series]): def _wrap_agged_manager(self, mgr: Manager) -> Series: out = self.obj._constructor_from_mgr(mgr, axes=mgr.axes) @@ -1555,6 +1558,7 @@ def unique(self) -> Series: return result +@set_module("pandas.api.typing") class DataFrameGroupBy(GroupBy[DataFrame]): _agg_examples_doc = dedent( """ diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py index 54e0453ed569b..2a96ef35c981c 100644 --- a/pandas/tests/api/test_api.py +++ b/pandas/tests/api/test_api.py @@ -420,3 +420,6 @@ def test_set_module(): assert pd.Series.__module__ == "pandas" assert pd.date_range.__module__ == "pandas" assert pd.bdate_range.__module__ == "pandas" + assert pd.NamedAgg.__module__ == "pandas" + assert api.typing.SeriesGroupBy.__module__ == "pandas.api.typing" + assert api.typing.DataFrameGroupBy.__module__ == "pandas.api.typing"