pandas的loc和iloc总结

参考
loc是基于标签的
iloc是基于数字的(如第几行第几列)



# 选择每一行的B和A两列
In [13]: df.loc[:, ['B', 'A']] = df[['A', 'B']]

In [14]: df
Out[14]: 
                   A         B
2000-01-01 -0.282863  0.469112
2000-01-02 -0.173215  1.212112
2000-01-03 -2.104569 -0.861849
2000-01-04 -0.706771  0.721555
2000-01-05  0.567020 -0.424972
2000-01-06  0.113648 -0.673690
2000-01-07  0.577046  0.404705
2000-01-08 -1.157892 -0.370647

你可能感兴趣的:(pandas的loc和iloc总结)