[SciPy-User] Quick question about selecting periodical data with scikits.timeseries

Pierre GM pgmdevlist at gmail.com
Fri Jan 15 15:56:47 EST 2010


On Jan 15, 2010, at 9:24 AM, Paweł Rumian wrote:
> hello,
> 
> Working more and more with scikits.timeseries and hydroclimpy I'm
> still impressed by their performance and abilities.
> 
> I cannot found, hovewer, a native method of selecting data included in
> a given (regular) period. Is there one?
> 
> In my particular case, I have daily data for the last fifteen years,
> and I'd like to split them into fifteen annual series, or 15*12
> monthly series, and so on...
> 
> I know I can select data from one period using something like:
> series.['1996-01-01':'1996-12-31']
> and of course I can write a function that will iterate over all years
> - but since I've found that many of the functions I wrote were
> included in the package, I don't want to make this mistake once more
> ;)


the easiest is to use the .convert method described here:
http://pytseries.sourceforge.net/generated/scikits.timeseries.TimeSeries.convert.html

In your case, choose 'A' for the output frequency  and func=None (the default) to get a Nx366 array of data; each row will correspond to a year, each column to a day of year (hence 366 columns to keep track of lapse years; for non-lapse year, the 366th element is masked).
A second possibility is to convert first to monthly frequency with an aggregation function (eg, func=sum or func=mean) to get a series of monthly aggregated data, then convert to 'A' to get a Nx12 series.
let me know if it helps or if you have more specific questions.
Cheers
P.


More information about the SciPy-User mailing list