首页 新闻 会员 周边 捐助

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

0
悬赏园豆:10 [待解决问题]

最近学习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,我试了几次发现这里的排序是按照字母的顺序来排的,不是自定义的箱名顺序,请问一下大神为什么会出现这样的结果?

步步为~营的主页 步步为~营 | 初学一级 | 园豆:192
提问于:2020-01-02 11:26
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册