Setting an index while reading data

By default, read_excel labels zeros with the numeric index, starting with 0. We can set our index or row labels to a higher value or to our choosing. To do this, we pass a column name from our dataset to the index_col option. In the following code, we are setting our index to the Title  column:

df = pd.read_excel('IMDB.xlsx', sheetname=0, index_col='Title')df.head()

The output is as follows:

Get Mastering Exploratory Analysis with pandas now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.