What is the proper way of converting integer dates to datetime64 in numpy? I tried:
import numpy
a = numpy.array([20090913, 20101020, 20110125])
numpy.datetime64(a.astype("S8"))
but get an incorrect conversion. How about reading them in correctly as numpy.datetime64 objects using numpy.loadtxt (they are coming from a csv file)?
Oddly, this works:
numpy.datetime64(a.astype("S8").tolist()), while this does not:numpy.datetime64(a.astype("S8")). The first method is still a bit less convoluted than:numpy.array([numpy.datetime64(str(i)) for i in a]). I asked why in this question.