1
無論我做什麼 - 無論我使用什麼Excel文件,我都無法打開它們。這是工作之前... 我做什麼:打開Excel文件時Pandas IndexError
import pandas as pd
xls = pd.ExcelFile('Book1.xls')
xls.parse('Sheet1', index_col=0, na_values=['None'])
或也
pd.read_excel('Book1.xls', 'Sheet1', index_col=0, na_values=['None'])
我能得到什麼:
IndexError Traceback (most recent call last)
<ipython-input-35-a09cadf6215b> in <module>()
2 xls = pd.ExcelFile('Book1.xls')
3 #test = xls.parse('SFH', index_col=0, na_values=['None'])
----> 4 pd.read_excel('Book1.xls', 'Sheet1', index_col=0, na_values=['None'])
/Users/xy/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/excel.pyc in read_excel(io, sheetname, **kwds)
101 engine = kwds.pop('engine', None)
102
--> 103 return ExcelFile(io, engine=engine).parse(sheetname=sheetname, **kwds)
104
105
/Users/xy/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/excel.pyc in parse(self, sheetname, header, skiprows, skip_footer, index_col, parse_cols, parse_dates, date_parser, na_values, thousands, chunksize, convert_float, has_index_names, **kwds)
206 skip_footer=skip_footer,
207 convert_float=convert_float,
--> 208 **kwds)
209
210 def _should_parse(self, i, parse_cols):
/Users/xy/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/excel.pyc in _parse_excel(self, sheetname, header, skiprows, skip_footer, index_col, has_index_names, parse_cols, parse_dates, date_parser, na_values, thousands, chunksize, convert_float, **kwds)
302 **kwds)
303
--> 304 return parser.read()
305
306 @property
/Users/xy/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/parsers.pyc in read(self, nrows)
624 raise ValueError('skip_footer not supported for iteration')
625
--> 626 ret = self._engine.read(nrows)
627
628 if self.options.get('as_recarray'):
/Users/xy/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/parsers.pyc in read(self, rows)
1459
1460 data = self._convert_data(data)
-> 1461 index, columns = self._make_index(data, alldata, columns, indexnamerow)
1462
1463 return index, columns, data
/Users/xy/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/parsers.pyc in _make_index(self, data, alldata, columns, indexnamerow)
791
792 elif not self._has_complex_date_col:
--> 793 index = self._get_simple_index(alldata, columns)
794 index = self._agg_index(index)
795
/Users/xy/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/io/parsers.pyc in _get_simple_index(self, data, columns)
834 data.pop(i)
835 if not self._implicit_index:
--> 836 columns.pop(i)
837
838 return index
IndexError: pop from empty list
難道我做錯了什麼?我應該提交一份錯誤報告嗎?
覺得有點笨。奇怪的是 - 這個劇本在幾個月前工作過... – n1000