[SciPy-User] Question about scikits.timeseries.lib.moving_funcs.mov_average
Wed Jun 23 09:48:04 CDT 2010
On Wed, Jun 23, 2010 at 10:40 AM, Pierre GM <firstname.lastname@example.org> wrote:
> On Jun 23, 2010, at 8:11 AM, Andreas wrote:
>> in the docstring to mov_average() it says:
>> The result will also be masked at i if any of the input values in the
>> slice ``[i-span:i+1]`` are masked
>> Is there any way to prevent this behaviour?
> Nope. That limits nasty surprises otherwise.
>> I have a very patchy
>> timeseries (one value every 3 to 6 days), and I'd like to use the
>> mov_average function to smooth these data.
>> Any idea how to do that?
>> mov_average(data,20) would have been perfect, if not for the masked values
>> What I tried so far is
>> but that has the same size as data.compressed(). I would really like to
>> have daily values ..
> You could try to fill your missing values beforehand, w/ functions like backward_fill and forward_fill, then passing your series to mov_average. Or the reverse way: compress your data to get rid of the missing values, pass it to mov_average, reconvert it to a daily series w/ fill_missing_dates (to get the right number of dates), then fill it w/ backward_fill or forward_fill.
> Let me know how it goes.
> SciPy-User mailing list
In pandas all my moving window functions accept a "min_periods"
argument so that it will place a value in a data hole assuming there
are sufficient observations in window:
In : arr
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., NaN,
NaN, NaN, NaN, NaN, 15., 16., 17., 18., 19.])
In : rolling_mean(arr, 10, min_periods=1)
array([ 0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. ,
4.5, 5. , 5.5, 6. , 6.5, 7. , 9. , 11. , 13. ,
15. , 17. ])
Have you thought of adding this functionality to scikits.timeseries?
More information about the SciPy-User