Skip to content
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Bug Fixes

- Bug in ``TimedeltaIndex`` addition where overflow was being allowed without error (:issue:`14816`)
- Bug in ``astype()`` where ``inf`` values were incorrectly converted to integers. Now raises error now with ``astype()`` for Series and DataFrames (:issue:`14265`)

- Bug in ``describe()`` when passing a numpy array which does not contain the median to the ``percentiles`` keyword argument (:issue:`14908`)



Expand Down
3 changes: 3 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5262,6 +5262,9 @@ def describe(self, percentiles=None, include=None, exclude=None):
raise ValueError("Cannot describe a DataFrame without columns")

if percentiles is not None:
# explicit conversion of `percentiles` to list
percentiles = list(percentiles)

# get them all to be in [0, 1]
self._check_percentile(percentiles)

Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,13 @@ def test_describe_percentiles_insert_median(self):
self.assertTrue('0%' in d1.index)
self.assertTrue('100%' in d2.index)

def test_describe_percentiles_insert_median_ndarray(self):
# GH14908
df = tm.makeDataFrame()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the issue number here as a comment

result = df.describe(percentiles=np.array([.25, .75]))
expected = df.describe(percentiles=[.25, .75])
assert_frame_equal(result, expected)

def test_describe_percentiles_unique(self):
# GH13104
df = tm.makeDataFrame()
Expand Down