[Numpy-discussion] RFC: A proposal for implementing some date/time types in NumPy

Francesc Alted falted@pytables....
Fri Jul 11 13:01:39 CDT 2008

A Friday 11 July 2008, Pierre GM escrigué:
> On Fri, Jul 11, 2008 at 12:47 PM, Francesc Alted
> <falted@pytables.org>
> wrote:
> > A Friday 11 July 2008, Pierre GM escrigué:
> > > Our approach for dealing with dates was to translate them into
> > > integers through a particular class (Date).
> >
> > That's very interesting.  We will have a look at your
> > implementation and see if we can reuse code/ideas.  I suppose this
> > code in your TimeSeries module, right?
> Yes, in the src directory (c_dates.c).
> In addition, we have a DateArray class, which implements an array of
> Dates (you didn't see that coming...) and whose dtype is int64.
> The reason why we wanted to stick to ints was to permit a direct
> correspondence index<->date in an array. If you know the first date
> and the timestep, you can get the date corresponding to any element
> of your series, and vice-versa.

Ah!  Very smart!  I wonder if we could use this to implement a special 
array with a fixed timestep that could be indexed by time instead than 
by index.  Something like:

t1 = datetime.datetime(1,2,3)
t2 = datetime.datetime(3,4,5)

and then:


would select the events between t1 and t2 timestamps.

Powerful!  But that would introduce more complexity and besides this is 
not directly related with our goal.  Interesting anyway.

Francesc Alted

More information about the Numpy-discussion mailing list