[SciPy-user] pytseries custom frequency
Mon May 11 18:56:07 CDT 2009
On May 11, 2009, at 7:12 PM, mudit sharma wrote:
> Is there a way to work with custom frequencies in pytseries? I have
> time series at freq 5 secs which I am looking to convert to 1 min, 5
> min, 30 min. I have looked at the docs and could find the way to
> achieve this. If not in pytseries is there any other package. any
> suggestions will be much appreciated.
Unfortunately not. The frequencies are hard-coded in C, and there's no
way to define some custom one (for the moment).
However, there might be some work around in your case that may not
require tseries, as the frequencies you want are simply related one to
* If your series is regularly spaced, without missing data, you're
good to go to the next step. Else, create a series with a _c.FR_SEC
frequency from your data, fill it with fill_missing_dates, and take
every 5 elements with something like series[::5].
* To convert to 1 minute, use series.reshape(-1,12) (12 periods of 5s
in 1min), so that each row corresponds to a minute. if you work w/ a
time series, just reshape the .series attribute (you don;t need the
dates anymore). Make sure the size of the series is indeed divisible
by 12. If not, create a masked array with a size of (initial_size//
12+1)*12 and fill it w/your data before reshaping.
* To convert to 5 minutes intervals, use a .reshape(-1,60)
* To convert to 30min intervals, use a .reshape(-1,360)
More information about the SciPy-user