Skip to content

CLN: Replace _selected_obj with _obj_with_exclusions in SeriesGroupBy #55392

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 1 commit into from
Oct 5, 2023
Merged
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
14 changes: 7 additions & 7 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _wrap_agged_manager(self, mgr: Manager) -> Series:
def _get_data_to_aggregate(
self, *, numeric_only: bool = False, name: str | None = None
) -> SingleManager:
ser = self._selected_obj
ser = self._obj_with_exclusions
single = ser._mgr
if numeric_only and not is_numeric_dtype(ser.dtype):
# GH#41291 match Series behavior
Expand Down Expand Up @@ -448,7 +448,7 @@ def _aggregate_named(self, func, *args, **kwargs):
initialized = False

for name, group in self.grouper.get_iterator(
self._selected_obj, axis=self.axis
self._obj_with_exclusions, axis=self.axis
):
# needed for pandas/tests/groupby/test_groupby.py::test_basic_aggregations
object.__setattr__(group, "name", name)
Expand Down Expand Up @@ -519,7 +519,7 @@ def _cython_transform(
):
assert axis == 0 # handled by caller

obj = self._selected_obj
obj = self._obj_with_exclusions

try:
result = self.grouper._cython_operation(
Expand All @@ -546,7 +546,7 @@ def _transform_general(

results = []
for name, group in self.grouper.get_iterator(
self._selected_obj, axis=self.axis
self._obj_with_exclusions, axis=self.axis
):
# this setattr is needed for test_transform_lambda_with_datetimetz
object.__setattr__(group, "name", name)
Expand Down Expand Up @@ -618,7 +618,7 @@ def true_and_notna(x) -> bool:
indices = [
self._get_index(name)
for name, group in self.grouper.get_iterator(
self._selected_obj, axis=self.axis
self._obj_with_exclusions, axis=self.axis
)
if true_and_notna(group)
]
Expand Down Expand Up @@ -1164,7 +1164,7 @@ def nlargest(
self, n: int = 5, keep: Literal["first", "last", "all"] = "first"
) -> Series:
f = partial(Series.nlargest, n=n, keep=keep)
data = self._selected_obj
data = self._obj_with_exclusions
# Don't change behavior if result index happens to be the same, i.e.
# already ordered and n >= all group sizes.
result = self._python_apply_general(f, data, not_indexed_same=True)
Expand All @@ -1175,7 +1175,7 @@ def nsmallest(
self, n: int = 5, keep: Literal["first", "last", "all"] = "first"
) -> Series:
f = partial(Series.nsmallest, n=n, keep=keep)
data = self._selected_obj
data = self._obj_with_exclusions
# Don't change behavior if result index happens to be the same, i.e.
# already ordered and n >= all group sizes.
result = self._python_apply_general(f, data, not_indexed_same=True)
Expand Down