import pandas as pd
df=pd.DataFrame({
"a":[1,2,3],
"b":[4,5,6],
"c":[7,8,9]
})
a b c
0 1 2 3
1 4 5 6
2 7 8 9 df1=df['a'] #<class 'pandas.core.series.Series'>
df2=df[['a','b']] #<class 'pandas.core.frame.DataFrame'>
#series取值
df1.ix[0,'a']
#dateframe取值
df2.ix[0,'b']
loc:根据标签
print(df2.loc[0:2,'a':'b'])#根据标签
a b
0 1 2
1 4 5
2 7 8
iloc:根据索引
print(df2.iloc[0:2,0:2])#根据索引
a b
0 1 2
1 4 5