loc and iloc in Python

From the Pandas cheat sheet ยท Select Rows and Columns ยท verified Aug 2026

loc and iloc

Select by labels or integer positions.

python
df.loc["ana", "score"]
df.iloc[0, 1]
๐Ÿ“Œ loc uses labels and iloc uses positions
๐Ÿ” Label slices include the stop label
โšก at and iat optimize scalar access
๐ŸŽฏ Use explicit indexers in reusable code
locilocselection

Continue with Pandas

Save the full cheat sheet or work through every related task.

More Python tasks

Back to the full Pandas cheat sheet