[SciPy-User] Question about scikits.timeseries.lib.moving_funcs.mov_average

Pierre GM pgmdevlist@gmail....
Wed Jun 23 09:40:16 CDT 2010

On Jun 23, 2010, at 8:11 AM, Andreas wrote:

> Hi,
> 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
>   mov_average(data.compressed(),20)
> 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.

More information about the SciPy-User mailing list