Skip to content

Commit

Permalink
REF: Use _python_apply_general internally (pandas-dev#52342)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhshadrach authored and topper-123 committed Apr 6, 2023
1 parent 82b793a commit 5ecae59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2685,7 +2685,9 @@ def dtypes(self) -> Series:
)

# error: Incompatible return value type (got "DataFrame", expected "Series")
return self.apply(lambda df: df.dtypes) # type: ignore[return-value]
return self._python_apply_general( # type: ignore[return-value]
lambda df: df.dtypes, self._selected_obj
)

@doc(DataFrame.corrwith.__doc__)
def corrwith(
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,14 @@ def f(self):
return self.plot(*args, **kwargs)

f.__name__ = "plot"
return self._groupby.apply(f)
return self._groupby._python_apply_general(f, self._groupby._selected_obj)

def __getattr__(self, name: str):
def attr(*args, **kwargs):
def f(self):
return getattr(self.plot, name)(*args, **kwargs)

return self._groupby.apply(f)
return self._groupby._python_apply_general(f, self._groupby._selected_obj)

return attr

Expand Down Expand Up @@ -1117,7 +1117,7 @@ def curried(x):
# special case otherwise extra plots are created when catching the
# exception below
if name in base.plotting_methods:
return self.apply(curried)
return self._python_apply_general(curried, self._selected_obj)

is_transform = name in base.transformation_kernels
result = self._python_apply_general(
Expand Down

0 comments on commit 5ecae59

Please sign in to comment.