我正在使用 numpy 1.8.2,以下代码导致以下错误:
import numpy as np
data = []
data.append(['2015-01-03 05:00:00', 5, 5.01])
data.append(['2015-01-04 05:00:00', 7, 7.01])
data.append(['2015-01-05 05:00:00', 8, 8.01])
data.append(['2015-01-06 05:00:00', 10, 10.01])
dt = np.dtype('M8', '<f8', '<f8')
np.array(data, dtype=dt)
产生以下输出:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-24-a3d77026bff9> in <module>()
9 dt = np.dtype('M8', '<f8', '<f8')
10
---> 11 np.array(data, dtype=dt)
ValueError: Could not convert object to NumPy datetime
有什么我做错了吗?
我特别困惑,因为
np.datetime64('2015-01-06 05:00:00')
产生预期的输出:
numpy.datetime64('2015-01-06T05:00:00-0500')