Python pandas.read\u excel的类型错误

Python pandas.read\u excel的类型错误,python,pandas,Python,Pandas,我无法加载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=panda

我无法加载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`
TypeError回溯(最近一次调用)
在里面
1.进口大熊猫
---->2 y=pandas.read_excel(“as.xlsx”,sheetname=0)
3岁
包装中的c:\users\lenovo pc\appdata\local\programs\python37\lib\site packages\pandas\util\\u decorators.py(*args,**kwargs)
206其他:
207 kwargs[新参数名称]=新参数值
-->208返回函数(*args,**kwargs)
209
210返回包装器
c:\users\lenovo pc\appdata\local\programs\python\37\lib\site packages\pandas\io\excel\u base.py在read\u excel中(io、工作表名称、页眉、名称、索引列、usecols、压缩、数据类型、引擎、转换器、真值、假值、skiprows、nrows、na值、保留默认值、详细、解析日期、日期解析器、千、注释、跳过页脚、skipfooter、转换浮点、压缩重复列、**kwds)
304如果参数单位为千瓦时:
305上升类型错误(
-->306“read_excel()获得意外的关键字参数“`{}`”。格式(arg)
307             )
308
TypeError:read_excel()获得意外的关键字参数'sheetname'`

您有语法错误

试一试

似乎此“sheet_name”可能与语言有关。此参数也是位置参数,因此您可以直接删除“sheet_name”并写入:

y=pandas.read_excel(“as.xlsx”,0)

我已使用以下命令在命令提示符下尝试了Pandas 1.0.5和xlrd 1.2.0版本

安装
xlrd

  • conda安装xlrd
  • pip安装xlrd

  • 它被称为
    Sheetname

    正确的参数是
    sheet\u name
    -请注意下划线。我投票以键入错误的形式结束。@DavidW。这不是键入错误,而是由运行旧代码引起的。参数
    Sheetname
    在2018年被折旧,然后被替换为
    sheet\u name
    。请参阅@mjfwest我不知道哦,这是一个有用的细节。Op的问题只是由一个简单的打字错误引起的,我认为这个答案在这里没有帮助。你可能想通过编辑它来澄清为什么你认为这是有帮助的。
    y=pandas.read_excel("as.xlsx",sheet_name=0)