使用python数据分析工具出错,single positional indexer is out-of-bounds
掌上鹅 2017-11-07 10:05:09 第一次用这几个工具。就出现好几个错误。
源代码:
# line plot of time series
from pandas import Series
from matplotlib import pyplot
# load dataset
series = Series.from_csv('car-sales.csv', header=0)
# display first few rows
print(series.head(5))
# line plot of dataset
series.plot()
pyplot.show()
报错代码:
File "/home/mrgan/文档/python_work/date_ku/car_sales.py", line 9, in <module>
series = Series.from_csv('car-sales.csv', header=0)
File "/usr/lib/python2.7/dist-packages/pandas/core/series.py", line 2476, in from_csv
result = df.iloc[:,0]
File "/usr/lib/python2.7/dist-packages/pandas/core/indexing.py", line 1225, in __getitem__
return self._getitem_tuple(key)
File "/usr/lib/python2.7/dist-packages/pandas/core/indexing.py", line 1449, in _getitem_tuple
self._has_valid_tuple(tup)
File "/usr/lib/python2.7/dist-packages/pandas/core/indexing.py", line 127, in _has_valid_tuple
if not self._has_valid_type(k, i):
File "/usr/lib/python2.7/dist-packages/pandas/core/indexing.py", line 1417, in _has_valid_type
return self._is_valid_integer(key, axis)
File "/usr/lib/python2.7/dist-packages/pandas/core/indexing.py", line 1431, in _is_valid_integer
raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds