直接上代码
pd.qcut(factors, 5).value_counts()
[-2.578, -0.829] 6
(-0.829, -0.36] 6
(-0.36, 0.366] 6
(0.366, 0.868] 6
(0.868, 2.617] 6
pd.cut(factors, 5).value_counts()
(-2.583, -1.539] 5
(-1.539, -0.5] 5
(-0.5, 0.539] 9
(0.539, 1.578] 9
(1.578, 2.617] 2
==显而易见,cut将根据值本身来选择箱子均匀间隔,qcut是根据这些值的频率来选择箱子的均匀间隔。
原文地址https://stackoverflow.com/questions/30211923/what-is-the-difference-between-pandas-qcut-and-pandas-cut