Skip to content

Fix bug in Series.describe where the median is included any time the percentiles argument is not None #61158

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 7 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor fixes
  • Loading branch information
MartinBraquet committed Mar 21, 2025
commit bf1effa1ad3f3f88b42ccfec2fdc305eabc51e93
8 changes: 2 additions & 6 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10818,12 +10818,8 @@ def describe(
----------
percentiles : list-like of numbers, optional
The percentiles to include in the output. All should
fall between 0 and 1. Here are the options:

- A list-like of numbers : To include the percentiles listed. If
that list is empty, no percentiles will be returned.
- None (default) : To include the default percentiles, which are the
25th, 50th, and 75th ones.
fall between 0 and 1. The default, ``None``, will automatically
return the 25th, 50th, and 75th percentiles.
include : 'all', list-like of dtypes or None (default), optional
A white list of data types to include in the result. Ignored
for ``Series``. Here are the options:
Expand Down
5 changes: 3 additions & 2 deletions pandas/tests/frame/methods/test_describe.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def test_refine_percentiles(self, percentiles):
if percentiles is None:
percentiles = [0.25, 0.5, 0.75]

expected = Series(
expected = DataFrame(
{
"count": len(df.a),
"mean": df.a.mean(),
Expand All @@ -440,6 +440,7 @@ def test_refine_percentiles(self, percentiles):
**{f"{p:.0%}": df.a.quantile(p) for p in percentiles},
"max": df.a.max(),
},
).to_frame(name="a")
index=["a"],
).T

tm.assert_frame_equal(result, expected)
Loading