# Picking Rows and Columns: loc and iloc

Square brackets pick columns by name, set_index makes a column such as sku the row labels, loc picks rows and columns by those labels (a label slice includes its end), and iloc picks them by position, counting from 0 (a position slice stops before its end).

![Cheat sheet: Picking Rows and Columns: loc and iloc](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/925b9330c9cf4cc3a54e27621bb89c55.webp)

- Category: Data Analysis
- Level: Apprentice
- Tags: iloc, loc, python, set_index(), Slicing
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/pandas-loc-and-iloc-cheat-sheet
