Import NumPy as NP from
Pandas import dataframe
import pandas as PD
Df=dataframe (Np.arange () reshape (3,4 ), index=[' One ', ' two ', ' THR '],columns=list (' ABCD ')
df[' A ' #取a列
df[[' A ', ' B ']] #取a, column B
#ix可以用数字索引, You can also use index and column indexes
df.ix[0] #取第0行
df.ix[0:1] #取第0行
df.ix[' one ': ' Two '] #取one, two row
df.ix[0:2,0] #取第0 , 1 rows, No. 0 column
df.ix[0:1, ' a '] #取第0行, column A
df.ix[0:2, ' A ': ' C '] #取第0, 1 lines, ABC column
df.ix[' one ': ' Two ', ' a ': ' C '] #取one, Two row, ABC column
df.ix[0:2,0:1] #取第0, 1 rows, No. 0 column
df.ix[0:2,0:2] #取第0, 1 rows, No. 0, 1 columns
#loc只能通过index和columns来取, cannot use a number
df.loc[' One ', ' a '] #one行, column A
df.loc[' one ': ' Two ', ' a '] #one到two行, column A
df.loc[' one ': ' Two ', ' a ': ' C ']# One to two row, a to C column
df.loc[' one ': ' Two ', [' A ', ' C ']] #one到two行, ac column
#iloc只能用数字索引, cannot be indexed
Df.iloc[0:2] #前2行
df.iloc[0] #第0行
df.iloc[0:2,0:2] #0, 1 rows, 0, 1 columns
df.iloc[[0,2],[1,2,3]] #第0, 2 rows, 1, 2, 3 columns
#iat取某个单值, Only digital index
df.iat[1,1] #第1行, 1 columns
#at取某个单值, only index and columns indexes
df.at[' One ', ' a '] #one行, column A