[SciPy-User] scikits.timeseries question

Pierre GM pgmdevlist@gmail....
Mon Nov 30 18:12:52 CST 2009


On Nov 30, 2009, at 6:58 PM, Christopher Barker wrote:
> HI all,
> 
> Maybe I'm missing something, but I can't seem to get this to work as I'd 
> like.

I guess you're confusing DateArrays and TimeSeries. DateArrays are just arrays of dates (think a ndarray of datetime objects, or a ndarray with a datetime64 dtype). TimeSeries are like MaskedArrays, the combination of a ndarray of values with 2 others ndarrays: one array of booleans (the mask), one DateArray.


> I have a bunch of data that is indexed by "day since Jan 1, 2001". It 
> seemed I should be able to do a DateArray like this:
> 
> In [40]: import scikits.timeseries as ts
> 
> In [41]: sd = ts.Date(freq='D', year=2001, month=1, day=1)
> 
> In [42]: sd
> Out[42]: <D : 01-Jan-2001>

All is well here.

> In [43]: da = ts.date_array((1,2,3,4), start_date=sd)

Check the doc for date_array: the first argument can be
        * an existing :class:`DateArray` object;
        * a sequence of :class:`Date` objects with the same frequency;
        * a sequence of :class:`datetime.datetime` objects;
        * a sequence of dates in string format;
        * a sequence of integers corresponding to the representation of 
          :class:`Date` objects.

So, what you're trying to do is to build a an array of four dates (1,2,3,4)
Instead, use that:

>>> ts.time_series((1,2,3,4),start_date=sd) 
timeseries([1 2 3 4],
   dates = [01-Jan-2001 ... 04-Jan-2001],
   freq  = D)

If you think the doc is confusing to that respect, please let me know how to improve it.
And of course, don't hesitate to contact me if you need further info
P.


More information about the SciPy-User mailing list