Xlsx files are very often the source of data that you analyze in Pandas. Today you will learn how to read multiple Excel sheets in Pandas.
Loading a file into Pandas is a basic skill. The difficulty starts when you want to do something out of the ordinary. Loading multiple sheets of Excel files is possible using the read_excel function.
How to read multiple Excel sheets
I know the names of the sheets so I will define the list of sheets beforehand. Then I’ll pass those lists as a parameter to the read_excel function. This way Pandas will load all defined sheets.
import pandas as pd sheets_list = ['Sheet1', 'Sheet2', 'Sheet3'] my_df = pd.read_excel("my_file.xlsx", sheet_name = sheets_list) print(my_df)
As you can see in the picture above, Pandas will load all defined sheets from Excel.
Documentation of read_excel function
How to change pandas version
How to plot a dataframe
How to write to existing Excel file in Pandas
How to save dataframe as Excel file
2 thoughts on “How to read multiple Excel sheets in Pandas”