Index

noun

say it: “IN-deks” /ˈɪndɛks/

In pandas, the labels that name each row of a table or each value of a column, used to find them; by default they are numbers counting up from 0.

What is the index of a pandas table?

The index is the labels of a pandas Series or DataFrame: one for each value or row, shown down the left side, used to find them. Without labels of your own, pandas numbers the rows from 0; you can give it names instead, such as products.

import pandas as pd
units = pd.Series([21, 20, 36], index=["lettuce", "honey jar", "sourdough loaf"])
print(units["honey jar"])    # 20

In a sentence

  • “The index ran from 0 to 5, one label for each sale.”
  • “With products as the index, she could look up the honey jar's units by name.”

Level: Journeyman · More Python terms at this level

Updated

In other subjects