Sometimes, we want to use Python Pandas with pd.read_excel() for multiple worksheets of the same workbook.
In this article, we’ll look at how to use Python Pandas with pd.read_excel() for multiple worksheets of the same workbook.
How to use Python Pandas with pd.read_excel() for multiple worksheets of the same workbook?
To use Python Pandas with pd.read_excel() for multiple worksheets of the same workbook, we can call read_excel
with the sheet name.
For instance, we write
xls = pd.ExcelFile('path_to_file.xls')
df1 = pd.read_excel(xls, 'Sheet1')
df2 = pd.read_excel(xls, 'Sheet2')
to read the excelt file with pd.ExcelFile
.
Then we call read_excel
with the xls
file handle and the sheet name.
Then we assign the returned data frame to variables.
Conclusion
To use Python Pandas with pd.read_excel() for multiple worksheets of the same workbook, we can call read_excel
with the sheet name.