求助:pandas模块cut函数中labels问题

最近学习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

你可能感兴趣的:(求助:pandas模块cut函数中labels问题)