Finding out sheet names

To find out the name of a sheet, pass the Excel file to the ExcelFile class and call the sheet_names property on the resulting object. The class prints the sheet names from the Excel file as a list. If we want to read data from a sheet named data-movies, it will look like the following code snippet:

xls_file = pd.ExcelFile('IMDB.xlsx')xls_file.sheet_names

Next, we call the parse method on the Excel file object we created earlier, and pass in the sheet names we want to read. We then assign the result to two separate DataFrame objects, as follows:

df1 = xls_file.parse('movies')df2 = xls_file.parse('by genre')df1.head()

We now have our data from two sheets in two separate DataFrames, as shown in the following screenshot: ...

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.