如何将 NumPy datetime64 转换为长整数并返回?
import numpy as np
import datetime
np.datetime64(datetime.datetime.now()).astype(long)
给出的值为 1511975032478959
np.datetime64(np.datetime64(datetime.datetime.now()).astype(long))
给出错误:
ValueError: Converting an integer to a NumPy datetime requires a specified unit
您需要指定 long int 的单位(在本例中为微秒)。
np.datetime64(np.datetime64(datetime.datetime.now()).astype(long), 'us')
returns
numpy.datetime64('2017-11-29T17:11:44.638713')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)