我有一个名为考试的资料框,我想根据常用顺序(一月、二月、三月、四月等)对月份列(即索引)进行排序。但是,它似乎是按升序排序的。我尝试了 reindex 命令,但没有任何区别。我怎样才能按我的意愿订购?
这是代码
exam.reindex(['January','February','March','April','May','June','July','August','September','October','November'])
这是资料框
uj5u.com热心网友回复:
你需要把它分配回来
exam = exam.reindex(['January','February','March','April','May','June','July','August','September','October','November'])
uj5u.com热心网友回复:
试试这个:
new_index = ['January','February','March','April','May','June','July','August','September','October','November']
exam = exam.loc[new_index]
0 评论