键入pandas.read_excel时出错

nvbavucw  于 2022-11-20  发布在  其他
关注(0)|答案(4)|浏览(301)

无法加载xlsx文件

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

这是错误消息

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`
tsm1rwdh

tsm1rwdh1#

语法错误
尝试

y=pandas.read_excel("as.xlsx",sheet_name=0)
avwztpqn

avwztpqn2#

这个“sheet_name”似乎与语言有关。参数也是位置性的,因此您只需删除“sheet_name”并写入:

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

我已经尝试了版本Pandas1.0.5和xlrd 1.2.0

gcxthw6b

gcxthw6b3#

语法错误。应为:

sheet_name = 'xxx'
nuypyhwy

nuypyhwy4#

使用以下命令从命令提示符安装xlrd

  1. conda install xlrd
  2. pip install xlrd
    它被称为Sheetname

相关问题