Skip to content

Glossary: pandas Basics

loc

Also written: .loc

Selects rows, and optionally columns, by label, as `.loc[rows, columns]`. A slice includes the end label, and it's also the safe way to change values: `df.loc[mask, "col"] = value`.

Where the book teaches it

Related terms

ilocBoolean filter (mask)