[Numpy-discussion] code review for datetime arange
Christopher Barker
Chris.Barker@noaa....
Thu Jun 9 15:41:40 CDT 2011
Mark Wiebe wrote:
> Because of the nature of datetime and timedelta, arange has to be
> slightly different than with all the other types. In particular, for
> datetime the primary signature is np.arange(datetime, datetime, timedelta).
>
> I've implemented a simple extension which allows for another way to
> specify a date range, as np.arange(datetime, timedelta, timedelta).
instead of, or in addition to, the above?
it seems you can pass in the following types:
strings
np.datetime64
np.timedelta64
integers
(floats ?)
Are you essentially doing method overloading to determine what it all means?
How do you know if:
np.arange('2011', '2020', dtype='M8[Y]')
means you want from the years 2011 to 2020 or from 2011 to 4031?
> >>> np.arange('today', 10, 3, dtype='M8')
> array(['2011-06-09', '2011-06-12', '2011-06-15', '2011-06-18'],
> dtype='datetime64[D]')
so dtype 'M8' defaults to increments of days?
of course, I've lost track of the difference between 'M' and 'M8'
(I've never liked the dtype code anyway -- I far prefer np.float64 to
'd', for instance)
Will there be a "linspace" for datetimes?
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
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@noaa.gov
More information about the NumPy-Discussion
mailing list