数据框具有
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

数据框具有
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