-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: cut() precision at the left end does not appear as specified (3 digits by default) #33912
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
Comments
Could you post a minimally reproducible example? Ideally not depending on graphics https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports |
ok I will do it, but need some time, since at the moment some deadlines to meet..... |
closing as I can't reproduce this - please do let us know if you can provide a reproducible example though and I'll reopen
|
@MarcoGorelli I can reproduce this too, one of the many issues with cut I faced in only a single day. Code to reproduce:
Two important points are |
Thanks @zareami10 , that reproduces the issue - much appreciated!
This sounds like a separate issue - could you open a new one with this one please? A reproducible example (like the one you posted here) would help to expedite resolution |
I believe there is a (2 years old) report for that, see issue #23164. Though I'm not sure how that could be improved without changing IntervalIndex as it it only accepts intervals which are closed on the same side (I'm quite new to pandas though, so might be missing something). Even in the code I provided I would expect an output of [1.195, 3.142] rather than (1.194, 3.142], even if we ignore the current issue. (Sorry for discussing it here, just thought I would explain a bit as I'm pointing to the issue) |
The bug appears to be in the rounding and adjust logic in _format_labels in pandas/core/reshape/tile.py pandas/pandas/core/reshape/tile.py Lines 582 to 585 in 1c82694
|
After a bit of analysis, I think the fix maybe simple. The pandas/pandas/core/reshape/tile.py Line 582 in 1c82694
However in line 585 the pandas/pandas/core/reshape/tile.py Line 585 in 1c82694
to this @simonjayhawkins What do you think, shall I submit a PR? |
take |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
You can find the complete code here:
https://github.com/nnworkspace/covid19-insight/blob/master/covid19-insight.ipynb
Problem description
I expected all bounds of the bins appear to be a rounded float with 3 digits of precision. But the output of above code (please pay attention to the first interval, the left bound):
0 (0.057999999999999996, 1.632] 39 39 39 39 39
1 (1.632, 3.19] 33 33 33 33 33
2 (3.19, 4.748] 27 27 27 27 27
3 (4.748, 6.305] 18 18 18 18 18
4 (6.305, 7.863] 12 12 12 12 12
5 (7.863, 9.421] 2 2 2 2 2
6 (9.421, 10.978] 3 3 3 3 3
7 (10.978, 12.536] 6 6 6 6 6
8 (12.536, 14.094] 2 2 2 2 2
9 (14.094, 15.652] 3 3 3 3 3
When the lower and upper bounds used as labels of a plot, it looks like this (pay attention to the first x-tick label )
Expected Output
(0.058, 1.632] should be the lower bound of the first interval, not an infinite number.
Output of
pd.show_versions()
pandas version: 1.0.3
The text was updated successfully, but these errors were encountered: