-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
The indexes of DataFrame.describe(percentiles=[0.29, 0.57, 0.58]) are incorrect #48298
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
Changes from 6 commits
e20d833
1e07daf
d331f2f
6e90e3a
223c843
f3dcaac
62fd28e
fd49aa7
2acd1f2
2f5cd77
f2479e8
86492c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1720,11 +1720,12 @@ def format_percentiles( | |
raise ValueError("percentiles should all be in the interval [0,1]") | ||
|
||
percentiles = 100 * percentiles | ||
percentiles_round_type = percentiles.round().astype(int) | ||
|
||
int_idx = np.isclose(percentiles.astype(int), percentiles) | ||
int_idx = np.isclose(percentiles_round_type, percentiles) | ||
|
||
if np.all(int_idx): | ||
out = percentiles.astype(int).astype(str) | ||
out = percentiles_round_type.astype(str) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the example in the original issue hit this path or the one below? Just want to make sure we have 2 tests that didn't work before and hit this change and the one below to work correctly now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
a) The example from issue will hit this path.
b) The example below I own create will hit below path.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have add test |
||
return [i + "%" for i in out] | ||
|
||
unique_pcts = np.unique(percentiles) | ||
|
@@ -1737,7 +1738,7 @@ def format_percentiles( | |
).astype(int) | ||
prec = max(1, prec) | ||
out = np.empty_like(percentiles, dtype=object) | ||
out[int_idx] = percentiles[int_idx].astype(int).astype(str) | ||
out[int_idx] = percentiles[int_idx].round().astype(int).astype(str) | ||
|
||
out[~int_idx] = percentiles[~int_idx].round(prec).astype(str) | ||
return [i + "%" for i in out] | ||
|
Uh oh!
There was an error while loading. Please reload this page.