[Numpy-discussion] The date/time dtype and the casting issue
Wed Jul 30 11:54:39 CDT 2008
On Wed, Jul 30, 2008 at 12:35 PM, Francesc Alted <firstname.lastname@example.org>wrote:
> A Wednesday 30 July 2008, Pierre GM escrigué:
> > In my mind, .tounit(*args) should be available for both relative
> > (timedeltas) and absolute (datetime) times.
> Well, what we are proposing is that the conversion time unit method for
> absolute times would be '.astype()' because its semantics is respected
> in this case.
> The problem is with relative times, and only with
> conversions between years or months and the rest of time units. This
> is why I propose the adoption of just a humble function for this cases.
> Introducing a method (.tounit()) for the ndarray object that only is
> useful for the date/time types seems a bit too much to my eyes (but I
> can be wrong, indeed).
Ohoh, I see... I was still thinking in terms of subclassing ndarray with a
timedelta class, where such a method would have made sense. In fact, you're
talking about the dtype. Well, of course, in that case, that makes sense not
to have an extra method. We can always implement it in Date/DateArray.
> > Now, what format do you consider for this reference ?
> Whatever that can be converted into a datetime64 scalar. Some examples:
> ref = '2001-04-01'
> ref = datetime.datetime(2001, 4, 1)
Er, should I see ref as having a 'day' unit or 'business day' unit in that
case? I know that 'business days' spoil the game, but Matt really needs
> > Moreover, could you give some more examples of interaction between
> > datetime and timedelta ?
> In the second proposal there are some examples of this interaction and
> I'm populating the third proposal with more examples yet. Just wait a
> bit (maybe a couple of hours) to see the new proposal.
OK, with pleasure. It's just that I have trouble understanding the meaning
of something like
t2 = numpy.ones(5, dtype="datetime64[s]")
That's five times one second after the epoch, right ? But in what
circumstances would you need t2 ?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion