3

Seems like this has an answer here and here already, however, none of these solutions are working for me.

I'm trying to do

xls = pd.ExcelFile('input.xls')
df = pd.read_excel(xls, sheet_name="Sheet2") ## Also tried sheet_name = 1

No matter what, df in the end still contains the first sheet instead of the second. I'm on Python 3 and Pandas 0.20.1 (Anaconda distro). What am I missing? How can I load the second sheet into df?

2
  • try to use sheetname instead of sheet_name. sheet_name replaced deprecated sheetname in Pandas 0.21.0 Commented Feb 15, 2018 at 13:53
  • That did it! Is the documentation incorrect? Commented Feb 15, 2018 at 13:54

1 Answer 1

3

from the docs:

sheetname : string, int, mixed list of strings/ints, or None, default 0

Deprecated since version 0.21.0: Use sheet_name instead

That also means that it used to be sheetname before the version 0.21.0 ;-)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.