我有两台计算机,均使用Anaconda,在笔记本上可以正常使用pd.read_excel()方法,而台式机则会报错
import pandas as pd
Records11 = pd.read_excel(u'hello.xlsx')
runfile('D:/python_work/bigstudy/test.py', wdir='D:/python_work/bigstudy')
Traceback (most recent call last):
File E:\Anaconda3\lib\site-packages\openpyxl\descriptors\base.py:55 in _convert
value = expected_type(value)
ValueError: could not convert string to float: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File D:\python_work\bigstudy\test.py:14 in <module>
Records11 = pd.read_excel(u'hello.xlsx')
File E:\Anaconda3\lib\site-packages\pandas\util\_decorators.py:311 in wrapper
return func(*args, **kwargs)
File E:\Anaconda3\lib\site-packages\pandas\io\excel\_base.py:465 in read_excel
data = io.parse(
File E:\Anaconda3\lib\site-packages\pandas\io\excel\_base.py:1458 in parse
return self._reader.parse(
File E:\Anaconda3\lib\site-packages\pandas\io\excel\_base.py:638 in parse
data = self.get_sheet_data(sheet, convert_float)
File E:\Anaconda3\lib\site-packages\pandas\io\excel\_openpyxl.py:575 in get_sheet_data
for row_number, row in enumerate(sheet.rows):
File E:\Anaconda3\lib\site-packages\openpyxl\worksheet\_read_only.py:79 in _cells_by_row
for idx, row in parser.parse():
File E:\Anaconda3\lib\site-packages\openpyxl\worksheet\_reader.py:151 in parse
obj = prop[1].from_tree(element)
File E:\Anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py:103 in from_tree
return cls(**attrib)
File E:\Anaconda3\lib\site-packages\openpyxl\worksheet\page.py:169 in __init__
self.left = left
File E:\Anaconda3\lib\site-packages\openpyxl\descriptors\base.py:67 in __set__
value = _convert(self.expected_type, value)
File E:\Anaconda3\lib\site-packages\openpyxl\descriptors\base.py:57 in _convert
raise TypeError('expected ' + str(expected_type))
TypeError: expected <class 'float'>
重新安装了Anaconda,但是不能解决
使用微软Excel打开文件后保存后,就可以用pd.read_excel()正常读了
希望能正常使用pd.read_excel()
你可以查看一下版本,有些高版本运行是会报错的。卸载台式机高版本,安装指定的版本就行了的