Skip to content

Commit 258cfc6

Browse files
committed
remove median percentile if user explictly pass blank list
- fixed docstring for percentiles behavior
1 parent 5cf9a70 commit 258cfc6

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

pandas/core/generic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10795,8 +10795,7 @@ def describe(
1079510795
The percentiles to include in the output. All should
1079610796
fall between 0 and 1. The default is
1079710797
``[.25, .5, .75]``, which returns the 25th, 50th, and
10798-
75th percentiles. If a blank list is passed, then returns
10799-
only the 50th percentile value.
10798+
75th percentiles.
1080010799
include : 'all', list-like of dtypes or None (default), optional
1080110800
A white list of data types to include in the result. Ignored
1080210801
for ``Series``. Here are the options:

pandas/core/methods/describe.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ def describe_ndframe(
7474
percentiles : list-like of numbers, optional
7575
The percentiles to include in the output. All should fall between 0 and 1.
7676
The default is ``[.25, .5, .75]``, which returns the 25th, 50th, and
77-
75th percentiles. If a blank list is passed, then returns only the
78-
50th percentile value.
77+
75th percentiles.
7978
8079
Returns
8180
-------
@@ -352,9 +351,9 @@ def _refine_percentiles(
352351
# explicit conversion of `percentiles` to list
353352
percentiles = list(percentiles)
354353

355-
# median should be included only if blank iterable is passed
354+
# percentiles are removed if an user explictly pass blank list
356355
if len(percentiles) == 0:
357-
return np.array([0.5])
356+
return np.array([])
358357

359358
# get them all to be in [0, 1]
360359
validate_percentile(percentiles)

0 commit comments

Comments
 (0)