[Numpy-discussion] The date/time dtype and the casting issue

Tom Denniston tom.denniston at alum.dartmouth.org
Wed Jul 30 13:44:04 EDT 2008


When people are refering to busienss days are you talking about
weekdays or are you saying weekday non-holidays?

On 7/30/08, Francesc Alted <faltet at pytables.org> wrote:
> A Wednesday 30 July 2008, Pierre GM escrigué:
> > > > 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 them, so...
>
> OK.  I was wrong.  Of course you need to specify the resolution, so the
> reference *should* be a NumPy scalar:
>
> ref = numpy.datetime64('2001-04-01', unit="B")  # 'B'usiness days
>
> >
> > > > 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 ?
>
> I'm not sure I follow you.  This is just an example so as to produce an
> array of time objects quickly.  In general, you should also be able to
> produce the same result by doing:
>
> t2 = numpy.array(['1970-01-01T00:00:05', '1970-01-01T00:00:05',
>                  '1970-01-01T00:00:05', '1970-01-01T00:00:05',
>                  '1970-01-01T00:00:05', dtype="datetime64[s]")
>
> which is more visual, but has the drawback that it's just too long for
> documenting purposes.  When you don't need the values for some
> examples, conciseness is a virtue.
>
> --
> Francesc Alted
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list