如何将 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')
返回
numpy.datetime64('2017-11-29T17:11:44.638713')
关于python - 将 numpy datetime64 转换为长整数并返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47562634/