[Numpy-discussion] datetime64
Alok Singhal
as8ca@mail.astro.virginia....
Thu Oct 29 15:22:31 CDT 2009
Hi,
On 29/10/09: 12:18, Ariel Rokem wrote:
> I want to start trying out the new dtype for representation of arrays
> of times, datetime64, which is implemented in the current svn. Is
> there any documentation anywhere? I know of this proposal:
>
> http://numpy.scipy.org/svn/numpy/tags/1.3.0/doc/neps/datetime-proposal3.rst
>
> but apparently the current implementation of the dtype didn't follow
> this proposal - the hypothetical examples in the spec don't work with
> the implementation.
> I just want to see a couple of examples on how to initialize arrays of
> this dtype, and what kinds of operations can be done with them (and
> with timedelta64).
I think the only thing that works as of now for dates and deltas is
using datetime.datetime and datetime.timedelta objects in the
initilization of the arrays. See
http://projects.scipy.org/numpy/ticket/1225 for some tests.
Even when you construct the arrays using datetime.datetime objects,
things are a bit strange:
In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.4.0.dev7599'
In [3]: import datetime
In [4]: d = datetime.datetime(2009, 10, 5, 12, 35, 2)
In [5]: d1 = datetime.datetime.now()
In [6]: np.array([d, d1], 'M')
Out[6]: array([2009-10-04 23:27:37.359744, 2009-10-29 00:10:59.677844], dtype=datetime64[ns])
-Alok
--
* *
Alok Singhal * * *
http://www.astro.virginia.edu/~as8ca/
* *
More information about the NumPy-Discussion
mailing list