Skip to content

ENH: Added explicit arguments in DataFrameGroupBy.describe by replacing **… #50653

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 9 commits into from
Jan 12, 2023
15 changes: 12 additions & 3 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2484,18 +2484,27 @@ def ohlc(self) -> DataFrame:
)

@doc(DataFrame.describe)
def describe(self, **kwargs):
def describe(
self,
percentiles=None,
include=None,
exclude=None,
) -> NDFrameT:
with self._group_selection_context():
if len(self._selected_obj) == 0:
described = self._selected_obj.describe(**kwargs)
described = self._selected_obj.describe(
percentiles=percentiles, include=include, exclude=exclude
)
if self._selected_obj.ndim == 1:
result = described
else:
result = described.unstack()
return result.to_frame().T.iloc[:0]

result = self._python_apply_general(
lambda x: x.describe(**kwargs),
lambda x: x.describe(
percentiles=percentiles, include=include, exclude=exclude
),
self._selected_obj,
not_indexed_same=True,
)
Expand Down