2

Importing Excel into a Pandas DataFrame without the Index giving me this error

TypeError: read_excel() got an unexpected keyword argument 'index'

As far as I can see, I am not doing any thing wrong here

import pandas as pd
df = pd.read_excel('Prod_User.xlsx', sheet_name='PROD', index=False)
print(df)

but getting the error! What might I be doing wrong here?

5
  • 3
    what about using index_col=0 instead of index=False? Commented Sep 27, 2023 at 14:28
  • 3
    The error says it already, remove index=False. Commented Sep 27, 2023 at 14:28
  • index parameter is not a valid argument for the read_excel() function, see pandas.pydata.org/docs/reference/api/pandas.read_excel.html Commented Sep 27, 2023 at 14:31
  • @Sauron TypeError for an argument that's not valid? Commented Sep 27, 2023 at 14:34
  • @wander95 I believe that's the Python default error; it can be interpreted as "the called function is not of correct type" Commented Sep 27, 2023 at 14:37

1 Answer 1

3

The read_excel function in Pandas does not take an argument Index. You can specify the index column using the index_col argument. This can be used to specify the row labels. The default value for this argument is none so from your example I don't think you need to use it. If you have an index column that you are trying to omit from the excel sheet you could use the "usecols" argument to specify what columns you would like to read. Please see Documenation for more info!

Hope this helps!

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.