1、Series
obj = pd.Series(range(5),index=['a','a','b','b','c']) #pandas支持重復索引

可以直接用Series['索引名']:obj['a']
也可以使用obj.a
loc和iloc同樣適用
2、DataFrame
frame = pd.DataFrame(np.arange(12).reshape(3,4),index=['one','two','three'],columns=['a','b','c','d')

使用DataFrame['列索引名']或者DataFrame.列索引名:frame['a']或frame.a
行索引使用loc:frame.loc['one']
使用iloc進行位置索引:frame.iloc[1,[2,0,1]]
注意:直接索引標簽名只適用於列索引,loc只適用於行索引,iloc默認先行索引后列索引,如果只有一個參數默認行索引;Series['索引名']和DataFrame['列索引名']當索引存在時引用或者修改,當索引不存在時添加新的索引,把索引當作Series對象或DataFrame對象的屬性索引時對不存在的索引無效。