Selecting Rows by Position
Use iloc (integer location) to select rows by their position, like indexing a list.
Get the first row:
df.iloc[0]
Get rows 2 through 5:
df.iloc[2:6]
Get specific rows by position:
df.iloc[[0, 5, 10]]
You can combine row and column selection. This gets rows 0-5, columns 0-2:
df.iloc[0:6, 0:3]
Position-based selection is useful when you need specific row numbers, like the first 100 rows for testing or every 10th row for sampling.
For complete indexing mastery, see The Ultimate Pandas Bootcamp.