loc and iloc

loc selects rows and columns by label, iloc by integer position. With loc, a slice includes the end bound; with iloc, it excludes it, as in Python. These accessors are also used to assign values unambiguously, rather than through chained indexing.

Example

df.loc[df['age'] > 30, 'nom']
df.iloc[0:3, 1]

Related concepts

The whole glossary