-
duplicates='drop'
-
decrease quantiles
-
Rank your data with DataFrame.rank(method=‘first’). The ranking assigns a unique value to each element in the dataframe (the rank) while keeping the order of the elements (except for identical values, which will be ranked in order they appear in the array, see method=‘first’)
Example:
pd.qcut(df, nbins)
<-- this generates “ValueError: Bin edges must be unique”
Then use this instead:
pd.qcut(df.rank(method='first'), nbins)
-
Specify a custom quantiles range, e.g. [0, .50, .75, 1.] to get unequal number of items per quantile
-
Use pandas.cut that chooses the bins to be evenly spaced according to the values themselves, while
pandas qcut error:duplicate bins
最新推荐文章于 2024-12-05 14:53:31 发布
