簡體   English   中英

類型錯誤 pandas.read_excel

[英]TypeError with pandas.read_excel

我無法加載 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`

你有一個語法錯誤

嘗試

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

似乎這個“sheet_name”可能與語言有關。 該參數也是位置性的,因此您可以刪除“sheet_name”並寫入:

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

我已經嘗試過 Pandas 1.0.5 和 xlrd 1.2.0 版

語法錯誤。 應該:

sheet_name = 'xxx'

使用以下命令從命令提示符安裝xlrd

  1. conda install xlrd
  2. pip install xlrd

它被稱為Sheetname

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM