Skip to content

Commit 0cd090a

Browse files
committed
FIX-#2596: revert groupby changes
Signed-off-by: Dmitry Chigarev <[email protected]>
1 parent 74ebfab commit 0cd090a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

modin/pandas/groupby.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,18 @@ def corr(self, **kwargs):
622622
return self._default_to_pandas(lambda df: df.corr(**kwargs))
623623

624624
def fillna(self, **kwargs):
625-
result = self._apply_agg_function(
626-
lambda df: df.fillna(**kwargs), overwrite_groupby_kwargs={"as_index": True}
625+
new_groupby_kwargs = self._kwargs.copy()
626+
new_groupby_kwargs["as_index"] = True
627+
work_object = type(self)(
628+
df=self._df,
629+
by=self._by,
630+
axis=self._axis,
631+
idx_name=self._idx_name,
632+
drop=self._drop,
633+
squeeze=self._squeeze,
634+
**new_groupby_kwargs,
627635
)
636+
result = work_object._apply_agg_function(lambda df: df.fillna(**kwargs))
628637
# pandas does not name the index on fillna
629638
result._query_compiler.set_index_name(None)
630639
return result
@@ -894,7 +903,7 @@ def _wrap_aggregation(
894903
return result.squeeze()
895904
return result
896905

897-
def _apply_agg_function(self, f, overwrite_groupby_kwargs=None, *args, **kwargs):
906+
def _apply_agg_function(self, f, *args, **kwargs):
898907
"""
899908
Perform aggregation and combine stages based on a given function.
900909
@@ -904,8 +913,6 @@ def _apply_agg_function(self, f, overwrite_groupby_kwargs=None, *args, **kwargs)
904913
----------
905914
f: callable
906915
The function to apply to each group.
907-
overwrite_groupby_kwargs: dict (optional),
908-
GroupBy kwargs to overwrite.
909916
910917
Returns
911918
-------
@@ -914,17 +921,15 @@ def _apply_agg_function(self, f, overwrite_groupby_kwargs=None, *args, **kwargs)
914921
assert callable(f) or isinstance(
915922
f, dict
916923
), "'{0}' object is not callable and not a dict".format(type(f))
917-
groupby_kwargs = self._kwargs.copy()
918-
if overwrite_groupby_kwargs is not None:
919-
groupby_kwargs.update(overwrite_groupby_kwargs)
924+
920925
new_manager = self._query_compiler.groupby_agg(
921926
by=self._by,
922927
is_multi_by=self._is_multi_by,
923928
axis=self._axis,
924929
agg_func=f,
925930
agg_args=args,
926931
agg_kwargs=kwargs,
927-
groupby_kwargs=groupby_kwargs,
932+
groupby_kwargs=self._kwargs,
928933
drop=self._drop,
929934
)
930935
if self._idx_name is not None and self._as_index:

0 commit comments

Comments
 (0)