NumPy analog of R's `filter`
Question: What is analog of R's
[`filter`](https://stat.ethz.ch/R-manual/R-patched/library/stats/html/filter.html)
in NumPy?

I have the following R code:

    
    
    f <- rep(1/9, 9)
    smth_x <- filter(x, f, sides=2)
    

Where `x` is some 1-D timeseries vector which may contain `nan`'s.

How to perform the same operation using NumPy? (or any other python libs)


Answer: I think the [scipy filter
functions](http://docs.scipy.org/doc/scipy/reference/signal.html) do what you
want, in particular
[lfilter](http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.lfilter.html).
Going from [this HOWTO](http://wiki.scipy.org/Cookbook/ApplyFIRFilter):

    
    
    import numpy, scipy.signal
    taps = numpy.repeat(1.0/9, 9)
    smoothed_x = scipy.signal.lfilter(taps, 1.0, x)
    

