最近学习pandas,其中:
ages = [20,22,25,27,21,23,37,31,61,45,41,32]
bins=[18,25,35,60,100]
group_names = ['Youth','YouthAdult','MiddleAged','Senior']
pd.cut(ages,bins,labels=group_names)
[Youth, Youth, Youth, YouthAdult, Youth, ..., YouthAdult, Senior, MiddleAged, MiddleAged, YouthAdult]
Length: 12
Categories (4, object):[MiddleAged < Senior < Youth < YouthAdult]
MiddleAged < Senior < Youth < YouthAdult应该为排序为:Youth < YouthAdult<MiddleAged < Senior,我试了几次发现这里的排序是按照字母的顺序来排的,不是自定义的箱名顺序,请问一下大神为什么会出现这样的结果?