[Numpy-discussion] Dates and times and Datetime64 (again)
chris.barker at noaa.gov
Mon Apr 28 13:40:49 EDT 2014
On Fri, Apr 25, 2014 at 4:57 AM, Andreas Hilboll <lists at hilboll.de> wrote:
> Array-wide access to the individual datetime components should work, i.e.,
> should yield an array of dtype int with the years. That would allow
> boolean indexing to filter data, like
> datetime64array[datetime64array.year == 2014]
> would yield all entries from 2014.
that would be nice, yes, but datetime64 doesn't support anything like that
at all -- i.e. array-wide or not access to the components. In this case,
you could kludge it with:
In : datetimearray
Out: array(['2014-02-03', '2013-03-08', '2012-03-07', '2014-04-06'],
In : datetimearray[datetimearray.astype('datetime64[Y]') ==
Out: array(['2014-02-03', '2014-04-06'], dtype='datetime64[D]')
but that wouldn't work for months, for instance.
I think the current NEP should stick with simply fixing the timezone thing
-- no new functionality or consequence.
Maybe it's time for a new NEP for what we want datetime64 to be in the
future -- maybe borrow from the blaze proposal cited earlier? Or wait and
see how that works out, then maybe port that code over to numpy?
In the meantime, a set of utilities that do the kind of things you're
looking for might make sense. You could do it as a ndarray subclass, and
add those sorts of methods, though ndarray subclasses do get messy....
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion