如何按索引对Pandas DataFrame排序?

如何按索引对Pandas DataFrame排序?,第1张

如何按索引对Pandas DataFrame排序

数据框具有

sort_index
默认情况下返回副本的方法。通过
inplace=True
*** 作就位

import pandas as pddf = pd.Dataframe([1, 2, 3, 4, 5], index=[100, 29, 234, 1, 150], columns=['A'])df.sort_index(inplace=True)print(df.to_string())

给我:

     A1    429   2100  1150  5234  3


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5431391.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存