【发布时间】:2020-03-17 07:55:46
【问题描述】:
根据response,我将子类型 datetime64[ns, US/Central] 与 np.datetime64 进行比较:
columns = self._obj.columns
for dtype in self._obj.dtypes:
print("testing:", dtype)
if np.issubdtype(dtype, np.datetime64):
...
testing: datetime64[ns, US/Central]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-2ddcb445a42c> in <module>
...
...(self, dataframe, *dataframes)
147 for dtype in self._obj.dtypes:
148 print("testing:", dtype)
--> 149 if np.issubdtype(dtype, np.datetime64):
...
TypeError: data type not understood
如果在此数据框中运行 head(),我会在该列中得到正常的时间戳:
ts
0 2020-02-22 12:11:40-06:00 NaN
1 2020-02-22 12:11:41-06:00 NaN
pandas.版本 '1.0.2'
numpy.版本 '1.18.1'
有任何想法吗?谢谢
【问题讨论】:
-
你可以在 GitHub 中打开一个问题,我觉得应该可以。看看你能不能把它变成一个纯粹的 numpy 问题(通过
.values访问底层的 numpy 数组),并在那里而不是在 pandas 中提出它:github.com/numpy/numpy -
你提出并发布了,它是否在 numpy 中得到修复?另外,如何将时区添加到 numpy datetime64,或者是 pandas?
-
没关系,一定是熊猫。不过,最新的 numpy 似乎仍然存在这个问题。