Note, the following imports are assumed throughout the documentation:
>>> import numpy as np >>> import numpy.ma as ma >>> import datetime >>> import scikits.timeseries as ts
There are three core objects central to the scikits.timeseries package. They are Date, DateArray, and TimeSeries. The sections that follow will go into detail on each of these classes. Understanding how these classes work and interact with each other is key to understanding the scikits.timeseries package as a whole.
The TimeSeries class is essentially just a subclass of MaskedArray with a date/time dimension attached to it (using a DateArray). Thus, it is helpful to have a solid understanding of how MaskedArray’s behave before diving into the scikits.timeseries package. Documentation for the numpy.ma module can be found at http://docs.scipy.org/doc/numpy/reference/maskedarray.html
As an example, let us construct a series of 600 random elements, starting 600 business days ago, at a business day frequency:
>>> data = np.random.uniform(-100,100,600) >>> today = ts.now('B') >>> series = ts.time_series(data, dtype=np.float32, freq='B', start_date=today-600)
>>> isinstance(series.dates, ts.DateArray) True >>> isinstance(series.series, ma.MaskedArray) True