设置索引
>>> df.set_index(['a','b']) #设置联合索引
e c yi
a b
0 1 0 2 3
4 5 4 6 7
8 9 8 10 11
取数
第一种:分次取
>>> df.loc[0].loc[1]
e 0
c 2
yi 3
第二种:
df.loc[ ( ) , ]
>>> df.loc[(0,1),:]
e 0
c 2
yi 3
Name: (0, 1), dtype: int32
>>> df.loc[(0,1),['e','c']]
e 0
c 2
Name: (0, 1), dtype: int32
排序:
df.sort_values(column,ascending=,na_position=‘last/fist’,inplace=)
重置index
df.reset_index(drop=True,inplacr=)
>>> df.sort_values('e',ascending=False,inplace=True)
>>> df
e c yi
a b
8 9 8 10 11
4 5 4 6 7
0 1 0 2 3
>>> df.reset_index(drop=True) #重置索引
e c yi
0 8 10 11
1 4 6 7
2 0 2 3