'Python qcut: At precision = 1, my first bin has obnoxiously long decimal value for left boundary
The following code creates quartile columns with bins:
for(a, c) in zip(colnames, cols):
cstats[c] = pd.qcut(cstats[a], 4, precision = 1)
I understand that even with precision set to 1 decimal place, the leftmost bin adjusts to include the smallest value in the dataset. I've seen some GitHub discussions around this problem, but would love an easy way to adjust any bin with a left value stretching to multiple decimal places rather than one. Current results look like this:
2020_QRange
0 (15.700000000000001, 37.0]
1 (37.0, 50.9]
2 (67.6, 184.0]
etc. What are my options to adjust that monstrosity? For example, how would I just round that down to 15.7?
Setting precision = 2 corrects the error but the result is too granular for my needs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|