1
我試圖繪製從我的熊貓DF,沿y軸索引x軸作爲一般散點圖的時間,但即使值I希望繪製都是相同的長度,我收到以下錯誤:熊貓情節指數超出界限但指數長度相等
raise IndexError("indices are out-of-bounds")
IndexError: indices are out-of-bounds
繪製指數(沿x軸)的代碼和在y軸上的時間差異如下:
fig = plt.figure()
ax = fig.add_axes([.1,.35,.6,.6])
ax=df.plot(ax=fig.gca(),kind='scatter',x=df.index, y=df.timediff, color='red', edgecolors='black')
plt.show()
df.timediff列的格式如下:
0 1970-01-01 00:19:14
1 1970-01-01 00:19:53
2 1970-01-01 00:23:50
Name: orb_timediff, dtype: datetime64[ns]
,並從輸出:
print(len(df.timediff))
print(len(df.index))
>>
291
291
完整的跟蹤堆棧低於:
Traceback (most recent call last):
File "9_tempscript.py", line 65, in <module>
ax=df.plot(ax=fig.gca(),kind='scatter',x=df.index, y=df.timediff, color='red', edgecolors='black')
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/tools/plotting.py", line 3774, in __call__
sort_columns=sort_columns, **kwds)
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/tools/plotting.py", line 2643, in plot_frame
**kwds)
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/tools/plotting.py", line 2470, in _plot
plot_obj.generate()
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/tools/plotting.py", line 1043, in generate
self._make_plot()
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/tools/plotting.py", line 1619, in _make_plot
scatter = ax.scatter(data[x].values, data[y].values, c=c_va lues,
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/core/frame.py", line 2053, in __getitem__
return self._getitem_array(key)
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/core/frame.py", line 2098, in _getitem_array
return self.take(indexer, axis=1, convert=True)
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/core/generic.py", line 1669, in take
convert=True, verify=True)
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/core/internals.py", line 3955, in take
indexer = maybe_convert_indices(indexer, n)
File "/opt/antelope/python2.7.8/lib/python2.7/site-packages/p andas/core/indexing.py", line 1873, in maybe_convert_indices
raise IndexError("indices are out-of-bounds")
IndexError: indices are out-of-bounds
您可以包括完整的堆棧跟蹤? –