Skip to content

Commit

Permalink
CLN: Replace _selected_obj with _obj_with_exclusions in SeriesGroupBy (
Browse files Browse the repository at this point in the history
  • Loading branch information
rhshadrach authored Oct 5, 2023
1 parent 940a1b4 commit a76b3f4
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit a76b3f4

Please sign in to comment.