fix unique bin error:
duplicates='drop '
删除质量
rankyourdatawithdataframe.rank (method=“first”).therankingassignsauniquevaluetoeachelementinthedataframe ) therank whilekeepingtheorderoftheelements (exceptforidenticalvalues,whichwillberankedinordertheyappearinthearrry,seemethod=‘fithod
Example:
PD.qcut(df,nbins )-- this generates谨慎的绿草: 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.] togetunequalnumberofitemsperquantile
use pandas.cutthatchoosesthebinstobeevenlyspacedaccordingtothevaluesthemselves,while pandas.qcutchoosesthebinssothatyouathouhatyouhatyouhavathatyouhavespallllesphespathespatt
Difference between qcut and cut
qcut:保证每组数量的平均
cut:由组内的values分开,组内不一定平均