<强> 更多大数据分析,建模等内容请关注公众号《bigdatamodeling》 强>
<代码> # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #排序# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 从熊猫进口DataFrame系列 # # # # #系列按索引排序sort_index方法返回新对象 obj=系列([1、3、2、5、6),指数=列表(“dabce”)) obj.sort_index () obj.sort_index(升序=False) # # # # #系列按值排序sort_values方法返回新对象 obj.sort_values () obj.sort_values(升序=False) # # # # # DataFrame按引索引/列索引排序, #默认轴=0,行索引排序 #轴=1,列索引排序 ?DataFrame (np.random。randn(4,3)、列=列表(dbe)指数=[‘Ut’,‘哦’,‘特克斯’,“矿”)) frame.sort_index() #同frame.sort_index(轴=0) frame.sort_index(升序=False) frame.sort_index(轴=1) 框架。sort_index(轴=1升=False) # # # # # DataFrame按列排序 ?DataFrame ({a: (1、3、1、5), b: [2、1、4、6]}) #这种方法但只适用python2 框架。排序(列=[a, b],提升=(真的,真的)) 框架。排序(列=[a, b],提升=[真,假]) # sort_index方法 框架。sort_index (=[a, b],提升=(真的,真的)) 框架。sort_index (=[a, b],提升=[真,假]) # sort_values方法 框架。sort_values (=[a, b],提升=(真的,真的)) 框架。sort_values (=[a, b],提升=[真,假])代码>