# set_index()

*noun*

say it: **“set IN-deks”** **/ˈsɛt ˈɪnˌdɛks/**

A pandas method that turns one of a table's columns, such as a product code, into the labels of its rows.

## What does **set_index()** do in pandas?

**set_index()** makes a column, such as a product code, the table's row labels (its index), and hands back the new
table. `loc` can then find a row by that label, and `reset_index()` turns the labels back into an ordinary column.

```python
catalog = products.set_index("sku")
print(catalog.loc["TO-1042", "product"])
```

## In a sentence

- “**set_index()** made the sku column the row labels.”
- “After **set_index()**, loc found each product by its code.”

Level: Journeyman · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/set-index
