-2
我正在通過簡單的熊貓教程。而我試圖繪製由dtype ='datetime64 [ns]'索引的DataFrame,但是,當我嘗試繪圖時,我假設matplotlib試圖將日期轉換爲浮點數,這會引發異常。獲取「TypeError:float()參數必須是一個字符串或數字」與熊貓的情節()
>>> df.index
DatetimeIndex(['2012-01-01', '2012-01-02', '2012-01-03', '2012-01-04',
'2012-01-05', '2012-01-06', '2012-01-07', '2012-01-08',
'2012-01-09', '2012-01-10',
...
'2012-12-22', '2012-12-23', '2012-12-24', '2012-12-25',
'2012-12-26', '2012-12-27', '2012-12-28', '2012-12-29',
'2012-12-30', '2012-12-31'],
dtype='datetime64[ns]', name=u'Date', length=366, freq=None)
>>> df.plot()
Traceback (most recent call last):
...
File "/usr/local/lib/python2.7/dist-packages/matplotlib/lines.py", line 676, in recache
x = np.asarray(xconv, np.float_)
File "/usr/local/lib/python2.7/dist-packages/numpy/core/numeric.py", line 531, in asarray
return array(a, dtype, copy=False, order=order)
TypeError: float() argument must be a string or a number
我在做什麼錯?
注:我下面很簡單的教程在這裏:http://nbviewer.jupyter.org/github/jvns/pandas-cookbook/blob/v0.1/cookbook/Chapter%201%20-%20Reading%20from%20a%20CSV.ipynb
DF [ 'Berri1'。圖()工作!我的壞 - 謝謝你的回覆 –
np,享受課程;) – Marcus