From baa1b284b9e64afc60ea711982d31fdbf6b69ca6 Mon Sep 17 00:00:00 2001 From: Kei Date: Thu, 18 Apr 2024 00:04:59 +0800 Subject: [PATCH] Move orig_obj arg in constructor to last param, to account for possible empty param --- pandas/core/groupby/generic.py | 2 +- pandas/core/groupby/groupby.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/groupby/generic.py b/pandas/core/groupby/generic.py index 23b785f282ca1..bbfc35b8e30b7 100644 --- a/pandas/core/groupby/generic.py +++ b/pandas/core/groupby/generic.py @@ -2048,7 +2048,6 @@ def _gotitem(self, key, ndim: int, subset=None): orig_obj = self.orig_obj if not self.observed else None return SeriesGroupBy( subset, - orig_obj, self.keys, level=self.level, grouper=self._grouper, @@ -2059,6 +2058,7 @@ def _gotitem(self, key, ndim: int, subset=None): group_keys=self.group_keys, observed=self.observed, dropna=self.dropna, + orig_obj=orig_obj, ) raise AssertionError("invalid ndim for _gotitem") diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index c41dfd818b255..7661902a65579 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -1097,7 +1097,6 @@ class GroupBy(BaseGroupBy[NDFrameT]): def __init__( self, obj: NDFrameT, - orig_obj: NDFrameT | None = None, keys: _KeysArgType | None = None, level: IndexLabel | None = None, grouper: ops.BaseGrouper | None = None, @@ -1108,6 +1107,7 @@ def __init__( group_keys: bool = True, observed: bool = False, dropna: bool = True, + orig_obj: NDFrameT | None = None, ) -> None: self._selection = selection