pandas read excel文件碰到的一个小问题

今天利用pandas读取excel时,爆出如下错误:

代码为:

import pandas as pd

db_eua=pd.read_excel('db_eua.xlsx',sheetname='EUA')
print(db_eua.read())


错误为:ImportError: No module named 'xlrd'

原来,pandas读取excel文件,需要单独的xlrd模块支持。

然后又碰到错误:

Traceback (most recent call last):
File "C:/pylearn/usepan.py", line 4, in <module>
print(db_eua.read())
File "C:\Python35\lib\site-packages\pandas\core\generic.py", line 3081, in __getattr__
return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'read'

 

 

仔细一看,自己马大哈了,因该是;head(),不是read()

 

修改后,运行结果如下;

Date Strip Price
0 2017-03-24 2017-03-17 4.78
1 2017-03-24 2017-12-17 4.86
2 2017-03-24 2017-12-18 4.91
3 2017-03-24 2017-12-19 4.98
4 2017-03-24 2017-12-20 5.10

转载于:https://www.cnblogs.com/aomi/p/6991522.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值