Use df.loc[] and df.iloc[] to select only
rows, only columns or both.
Use df.at[] and df.iat[] to access a single
value by row and column.
First index selects rows, second index columns.
Select rows 10-20.
df.iloc[10:20]
Select columns in positions 1, 2 and 5 (first
column is 0)
df.iloc[:, [1, 2, 5]]
Select all columns between x2 and x4 (inclusive)
df.loc[:, 'x2':'x4']
Select rows meeting logical condition, and only the specific columns
df.loc[df['a'] > 10, ['a’, 'c']]
Access single value by index
df.iat[1, 2]
Access single value by label
df.at[4, 'A']
Last changeda year ago