[SciPy-User] scikits.timeseries question
Mon Nov 30 22:03:22 CST 2009
On Nov 30, 2009, at 9:59 PM, Robert Ferrell wrote:
> This seems natural to me, (array + Date = array) although I do have to
> include an extra line sometimes to get a DateArray if I need it. If I
> need a timeseries, sometimes I can skip making the DateArray explicitly.
Well, keep in mind that Date was implemented a few years ago already, far before the new datetime64 dtype, and it was the easiest way we had to define a new datatype (well, a kind of datatype). I'll check how we can merge the two approaches when I'll have some time.
Anyhow, in practice, a Date object will be seen as a np.object by numpy, and you end up having a ndarray with a np.object dtype.
> Is the issue that sd is a Date and not a DateArray? You can always
> make a DataArray with sd, of the correct length, and then add to that:
> In : sd = ts.Date('d', '2001-01-01')
> In : d1 = ts.date_array(zeros(4) + sd)
Wow, that's overkill ! Just make sd a DateArray:
>>> np.arange(4) + ts.DateArray(sd)
Now, because DateArray is a subclass of ndarray with a higher priority, its _add__ method takes over and the ouput is a DateArray.
>> and I'm still confused about what this means:
>>>> In : da = ts.date_array((1,2,3,4), start_date=sd)
> This throws an exception for me.
> <type 'exceptions.ValueError'>: year=1 is before 1900; the datetime
> strftime() methods require year >= 1900
What version are you using ? And anyway, you get the exception only if you try to print it (as strftime is called only when calling repr/str)
More information about the SciPy-User