Pandas cannot read a specific Excel worksheet… here is a solution to the problem.
Pandas cannot read a specific Excel worksheet
As if there is an answer to thishere and here However, none of these solutions worked for me.
I’m working on it
xls = pd. ExcelFile('input.xls')
df = pd.read_excel(xls, sheet_name="Sheet2") ## Also tried sheet_name = 1
In any case, df
still contains the first sheet in the end instead of the second. I’m using Python 3 and Pandas 0.20.1 (Anaconda distribution). What am I missing? How do I load a second sheet into df
?
Solution
From docs :
sheetname : string, int, mixed list of strings/ints, or None, default
0Deprecated since version 0.21.0: Use
sheet_name
instead
This also means that it used to be sheetname
before version 0.21.0
😉