我有这个:
dfData['dt']
Out[53]:
0 2013-01-02
1 2016-10-20
Name: dt, dtype: datetime64[ns]
我尝试这样:
dfData['dt'].dtype==np.datetime64
Out[56]: False
我也尝试这样:
isinstance(dfData['dt'], pd.DatetimeIndex)
Out[62]: False
我究竟做错了什么?如何识别一般日期类型?
使用功能numpy.issubdtype
:
print (np.issubdtype(dfData['dt'].dtype, np.datetime64))
True
熊猫解决方案functions for check dtypes
:
from pandas.api.types import is_datetime64_any_dtype
print (is_datetime64_any_dtype(dfData['dt'].dtype))
True
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句