[英]"TypeError: data type not understood" comparing dtype np.datetime64
as per this response , I'm comparing a subtype datetime64[ns, US/Central] to np.datetime64 :根据此回复,我将子类型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
if run head() in this dataframe I get normal timestamps in that column:如果在这个数据帧中运行 head() ,我会在该列中得到正常的时间戳:
ts
0 2020-02-22 12:11:40-06:00 NaN
1 2020-02-22 12:11:41-06:00 NaN
pandas.熊猫。 version '1.0.2'版本“1.0.2”
numpy.麻木。 version '1.18.1'版本“1.18.1”
any ideas?有任何想法吗? thanks谢谢
not ideal, but I fixed this with string comparison:不理想,但我用字符串比较解决了这个问题:
if (str(dtype).startswith("datetime64")):
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.