【发布时间】:2018-10-17 18:06:47
【问题描述】:
我有以下数据框:
YearMonth Total Cost
2015009 $11,209,041
2015010 $20,581,043
2015011 $37,079,415
2015012 $36,831,335
2016008 $57,428,630
2016009 $66,754,405
2016010 $45,021,707
2016011 $34,783,970
2016012 $66,215,044
YearMonth 是一个 int64 列。 YearMonth 中的一个值(例如 2015009)代表 2015 年 9 月。我想重新排序行,以便如果最后 3 位数字相同,那么我希望这些行按年份排序显示在彼此的顶部。
下面是我想要的输出:
YearMonth Total Cost
2015009 $11,209,041
2016009 $66,754,405
2015010 $20,581,043
2016010 $45,021,707
2015011 $37,079,415
2016011 $34,783,970
2015012 $36,831,335
2016012 $66,215,044
2016008 $57,428,630
我已经搜索了谷歌,试图找到如何做到这一点,但无济于事。
【问题讨论】:
标签: python sorting search integer