[SciPy-user] Calculating daily averages from a timeseries without using the timeseries package.

Pierre GM pgmdevlist@gmail....
Tue Dec 2 14:44:40 CST 2008


Installing and starting to use scikits.timeseries will take you a  
couple of hours, unless you're on windows (because I don't have access  
to a windows machine and can't help you with the installation).
Trying to find a trick to solve your problem might take you as long,  
if not more. If I were you, I wouldn't hesitate

But well, some ideas
1. Revert to an array of datetime objects instead of your datenum.
2. Define some function that tests the .day of your dates, and select  
the ones that match the day you want.

or, just convert your date2num floats to int and select the int that  
correspond to your day.

3. Constrct a mask from the results of the previous step.
4. Apply the mask on your data and compute the average.
5. Rinse and repeat for a new day.

Yep, laborious...
With scikits.timeseries, it'd be something like that:
series = ts.fill_missing_dates(series).convert('D').mean(-1)

More information about the SciPy-user mailing list