Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: set __module__ on NamedAgg / SeriesGroupBy / DataFrameGroupBy (pandas.core.groupby.generic classes) #60268

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
Appender,
Substitution,
doc,
set_module,
)
from pandas.util._exceptions import find_stack_level

Expand Down Expand Up @@ -108,6 +109,7 @@
ScalarResult = TypeVar("ScalarResult")


@set_module("pandas")
class NamedAgg(NamedTuple):
"""
Helper for column specific aggregation with control over output column names.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1555,6 +1558,7 @@ def unique(self) -> Series:
return result


@set_module("pandas.api.typing")
class DataFrameGroupBy(GroupBy[DataFrame]):
_agg_examples_doc = dedent(
"""
Expand Down
3 changes: 3 additions & 0 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading