'Binning with qcut, cant raise

I have a dataset with lots of duplicate values. Still, I want to bin the dataset! As I understood, there are two possibilities, to drop duplicate values (which makes perfectly sense me) and 'raise' (raise would mean to keep them and count them within the bin?). But for some reason, if I set duplicates='raise' then I get the following error ValueError: Bin edges must be unique: array([ 0. , 14.09240414, 31. , 31. , 31. , 31. ]).

When I'm using the 'drop' attribute, my bins get very uneven, the only workaround I found so far, is to rank each value. Would you have any ideas?

Also, is there a possibility to count the dropped values and display them in a separate bin?

Best, Hannes



Solution 1:[1]

It's because 'raise' means raise an error; not include the 0's. Facing the same thing myself.

Here's the documentation: https://pandas.pydata.org/docs/reference/api/pandas.qcut.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lucinda