[SciPy-user] creating timeseries for non convertional custom frequencies

Matt Knox mattknox_ca@hotmail....
Thu Apr 3 19:59:40 CDT 2008


> How do I create a timeseries object with custom or irregular frequencies?
> 
> Here a more verbose explanation of what I want:
> I have data that has been recorded from a data logger. Due to memory
> constraints, the logger has been set to only save the observations
> on a 5-minute basis (1 data point every 5 minutes).
> How do I create a hourly data set / timeseries from such a data?

Custom frequencies per say, are not currently supported. However, a TimeSeries
object does not have to have continuous dates strictly speaking. A 'minutely'
frequency series can have 1 data point every five minutes if you want. For
example...

=============================
import scikits.timeseries as ts
dates = []
for x in range(5):
    dates.append(ts.Date(freq='minutely', year=2008, month=1, day=1, hour=1,
minute=(x+1)*5))

series = ts.time_series(range(5), dates=dates, freq='minutely')
=============================

the above code generates a minutely frequency series with irregularly spaced
dates. You can even convert this series to other frequencies, however it will be
"stretched out" to a regularly spaced TimeSeries first (with masked values
inserted) before doing so. So you could do...

daily_series = series.convert('daily')

which would result in a 2d series with a lot of masked values, but if you are
just interested in things like averages, standard deviations, etc...  you can
use the relevant functions from the numpy.ma module and it will work fine.

All that being said... in a perfect world there would be a way to define custom
frequencies like "once every 5 minutes", which wouldn't involve a bunch of extra
masked values when converting to other frequencies. But this simply isn't
implemented yet. It is something that has been contemplated before, but it will
be non-trivial to implement and Pierre and myself have no pressing need for it
as far as I know, so we will have to wait for a motivated volunteer to come
along that is in desparate need of this functionality for it to be implemented.

- Matt



More information about the SciPy-user mailing list