Skip to content

DEPR: deprecate obj argument in GroupBy.get_group #53571

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

Merged
Merged
Changes from 1 commit
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
13 changes: 3 additions & 10 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,22 +906,18 @@ def pipe(
return com.pipe(self, func, *args, **kwargs)

@final
def get_group(self, name, obj=None) -> DataFrame | Series:
def get_group(self, name) -> DataFrame | Series:
"""
Construct DataFrame from group with provided name.

Parameters
----------
name : object
The name of the group to get as a DataFrame.
obj : DataFrame, default None
The DataFrame to take the DataFrame out of. If
it is None, the object groupby was called on will
be used.

Returns
-------
same type as obj
DataFrame
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small issue: I think that it returns Series or DataFrame

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I rolled back my changes there completely.


Examples
--------
Expand Down Expand Up @@ -955,14 +951,11 @@ def get_group(self, name, obj=None) -> DataFrame | Series:
owl 1 2 3
toucan 1 5 6
"""
if obj is None:
obj = self._selected_obj

inds = self._get_index(name)
if not len(inds):
raise KeyError(name)

return obj._take_with_is_copy(inds, axis=self.axis)
return self._selected_obj.iloc[inds]

@final
def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]:
Expand Down