无法使用 pandas 读取_excel [英] Can't read_excel with pandas

查看:244
本文介绍了无法使用 pandas 读取_excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习pandas lib.在Python3中,但是我有一个大问题.当我使用命令read_excel时出现错误.

I am learning pandas lib. in Python3, but i have a big problem. When i use command to read_excel i get an error.

import pandas as pd

df = pd.read_excel(r'D:\PythonProjects\stocks.xlsx',sheetname=0)

错误看起来像这样:

C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\util\_decorators.py:118: FutureWarning: The `sheetname` keyword is deprecated, use `sheet_name` instead
  return func(*args, **kwargs)
Traceback (most recent call last):
  File "D:/MyPythonProjects/urlib.py", line 4, in <module>
    df = pd.read_excel(r'D:\MyPythonProjects\NewL\stocksa.xlsx',sheetname=0 )
  File "C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\util\_decorators.py", line 118, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\io\excel.py", line 230, in read_excel
    io = ExcelFile(io, engine=engine)
  File "C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\io\excel.py", line 294, in __init__
    self.book = xlrd.open_workbook(self._io)
  File "C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\xlrd\__init__.py", line 141, in open_workbook
    ragged_rows=ragged_rows,
  File "C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\xlrd\xlsx.py", line 808, in open_workbook_2007_xml
    x12book.process_stream(zflo, 'Workbook')
  File "C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\xlrd\xlsx.py", line 265, in process_stream
    meth(self, elem)
  File "C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\xlrd\xlsx.py", line 392, in do_sheet
    sheet = Sheet(bk, position=None, name=name, number=sheetx)
  File "C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\xlrd\sheet.py", line 326, in __init__
    self.extract_formulas = book.extract_formulas
AttributeError: 'Book' object has no attribute 'extract_formulas'

我不知道如何解决它.我尝试重新安装pandas,xlrd,但仍然收到相同的错误.你能给我个建议如何解决这个问题.

I don't know how to fix it. I 've tried to reinstall pandas, xlrd and still i get the same error. Can you give me an advice how to repair that problem.

推荐答案

尝试安装

xlrd版本'0.9.4'

xlrd version '0.9.4'

为我工作

这篇关于无法使用 pandas 读取_excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆