Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError with pandas.read_excel

Tags:

python

pandas

I can't load the xlsx file

import pandas
y=pandas.read_excel("as.xlsx",sheetname=0)
y

This is the error message

TypeError                                 Traceback (most recent call last)
<ipython-input-5-54208838b8e5> in <module>
      1 import pandas
----> 2 y=pandas.read_excel("as.xlsx",sheetname=0)
      3 y

c:\users\lenovo-pc\appdata\local\programs\python\python37\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)
    206                 else:
    207                     kwargs[new_arg_name] = new_arg_value
--> 208             return func(*args, **kwargs)
    209 
    210         return wrapper

c:\users\lenovo-pc\appdata\local\programs\python\python37\lib\site-packages\pandas\io\excel\_base.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, verbose, parse_dates, date_parser, thousands, comment, skip_footer, skipfooter, convert_float, mangle_dupe_cols, **kwds)
    304         if arg in kwds:
    305             raise TypeError(
--> 306                 "read_excel() got an unexpected keyword argument " "`{}`".format(arg)
    307             )
    308 

TypeError: read_excel() got an unexpected keyword argument `sheetname`
like image 604
souvik dan Avatar asked Aug 04 '19 16:08

souvik dan


People also ask

What is read_excel in pandas?

pandas. read_excel() function is used to read excel sheet with extension xlsx into pandas DataFrame. By reading a single sheet it returns a pandas DataFrame object, but reading two sheets it returns a Dict of DataFrame.

Can pandas read_excel read CSV?

In order to read data from csv or excel files you can use pandas library. The function is read_csv() or read_excel() from pandas. You have to provide the file path as a string. Make sure the file name and extension is also given in the path.

How do you read a specific excel sheet in pandas?

To read an excel file as a DataFrame, use the pandas read_excel() method. You can read the first sheet, specific sheets, multiple sheets or all sheets. Pandas converts this to the DataFrame structure, which is a tabular like structure.

What does read_excel return in Python?

read_excel(target_file, sheet_name = None) returns a Dict . When you loop over data you get the keys of the Dict .


1 Answers

You have a syntax error

Try

y=pandas.read_excel("as.xlsx",sheet_name=0)
like image 64
Neha Jirafe Avatar answered Sep 20 '22 22:09

Neha Jirafe