-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fixed DataFrame.describe percentiles are ndarray w/ no median #14914
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
BUG: Fixed DataFrame.describe percentiles are ndarray w/ no median #14914
Conversation
Thx, can u add tests and whatsnew? |
@@ -5255,6 +5255,9 @@ def abs(self): | |||
|
|||
@Appender(_shared_docs['describe'] % _shared_doc_kwargs) | |||
def describe(self, percentiles=None, include=None, exclude=None): | |||
# explicit conversion of `percentiles` to list | |||
percentiles = list(percentiles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks fail by default percentiles=None
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right - I think I could just move it under if percentiles is not None:
instead
Current coverage is 84.64% (diff: 100%)@@ master #14914 diff @@
==========================================
Files 144 144
Lines 51057 51016 -41
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43180 43185 +5
+ Misses 7877 7831 -46
Partials 0 0
|
@@ -996,6 +996,15 @@ 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): | |||
df = tm.makeDataFrame() |
There was a problem hiding this comment.
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
@@ -996,6 +996,15 @@ 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): | |||
df = tm.makeDataFrame() | |||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need the try/except at all; nose will simply fail the test if this raises.
rename d1 -> result, d2 -> expected
small changes. ping on green. |
lgtm. ping on green. |
thanks! |
Explicit conversion to list for `percentiles`. Fixes the case where `percentiles` is passed as a numpy with no median (0.5) present. Closes pandas-dev#14908. Author: pbreach <[email protected]> Closes pandas-dev#14914 from pbreach/df-describe-percentile-ndarray-no-median and squashes the following commits: 5c8199b [pbreach] Minor test fix b5d09a6 [pbreach] Added test for median insertion with ndarray 72fe0cb [pbreach] Added what's new entry f954392 [pbreach] Moved conversion to if percentiles is not None d192ac7 [pbreach] Fixed whitespace issue a06794d [pbreach] BUG: Fixed bug in DataFrame.describe when percentiles are passed as array with no median
Explicit conversion to list for
percentiles
. Fixes the case wherepercentiles
is passed as a numpy with no median (0.5) present. Closes #14908.