1
test = pd.DataFrame({'counts':[0,1,2,3,4,5,6,11,12,14,15]})
test['range'] = pd.cut(test.counts, [0,5,10,15], include_lowest=True)
test
输出:
counts range
0 0 (-0.001, 5.0]
1 1 (-0.001, 5.0]
2 2 (-0.001, 5.0]
3 3 (-0.001, 5.0]
4 4 (-0.001, 5.0]
5 5 (-0.001, 5.0]
6 6 (5.0, 10.0]
7 11 (10.0, 15.0]
8 12 (10.0, 15.0]
9 14 (10.0, 15.0]
10 15 (10.0, 15.0]
我能得到(0, 5.0]
代替(-0.001, 5.0]
为什么-0.001显示,即使我没?没有指定它?
我想'箱= [0,5,10,15]'这是不是在你的代码所示。 – Cheng
@Cheng,是的,抱歉 - 忘了提及那个。 :) – MaxU