[Numpy-discussion] Implicit conversion of python datetime to numpy datetime64?
Charles R Harris
Tue Feb 14 23:05:19 CST 2012
On Tue, Feb 14, 2012 at 9:17 PM, Benjamin Root <email@example.com> wrote:
> Just a thought I had. Right now, I can pass a list of python ints or
> floats into np.array() and get a numpy array with a sensible dtype. Is
> there any reason why we can't do the same for python's datetime? Right
> now, it is very easy for me to make a list comprehension of datetime
> objects using strptime(), but it is very awkward to make a numpy array out
> of it.
> The only barrier I can think of are those who have already built code
> around a object dtype array of datetime objects.
> Ben Root
> P.S. - what ever happened to arange() and linspace() for datetime64?
Arange works in the development branch,
In : arange(0,3,1, dtype="datetime64[D]")
Out: array(['1970-01-01', '1970-01-02', '1970-01-03'],
but linspace is more complicated in that it might not be possible to
subdivide an interval into reasonable datetime64 units
In : a = datetime64(0, 'D')
In : b = datetime64(1, 'D')
In : linspace(a, b, 5)
Out: array(['1970-01-01', '1970-01-01', '1970-01-01', '1970-01-01',
Looks like a project for somebody. There is probably a lot of work along
that line to be done.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion