missing data

Filling missing data in python timeseries

I am using the ‘SCIKITS.TIMESERIES‘ python library for time series analysis. Here is how to fill the missing dates and the default data in the time series. The version 0.91.3 has bug in its timeseries.fill_missing_dates() method. One of the arguments it takes is fill_value, this is the default value we want to set for the missing data. But it does not work as intended. In fact the missing data is masked. To fill in the required data one must use the timeseries.filled(fill_value) method. Here is an example:

>>>import scikits.timeseries as ts

>>> datarr = ts.date_array(['2009-01-01', '2009-01-05'], freq='D')
>>> datarr
DateArray([01-Jan-2009, 05-Jan-2009],
freq='D')

>>> sr1 = ts.time_series([3,4], datarr)
>>> sr1
timeseries([3 4],
dates = [01-Jan-2009 05-Jan-2009],
freq  = D)

>>> m1 = sr1.fill_missing_dates(fill_value=0)
>>> m1
timeseries([3 -- -- -- 4],
dates = [01-Jan-2009 ... 05-Jan-2009],
freq  = D)

>>> m1.filled(0)
timeseries([3 0 0 0 4],
dates = [01-Jan-2009 ... 05-Jan-2009],
freq  = D)