[Numpy-discussion] Filling gaps

Pierre GM pgmdevlist@gmail....
Thu Feb 12 19:33:26 CST 2009


On Feb 12, 2009, at 8:22 PM, A B wrote:

> Hi,
> Are there any routines to fill in the gaps in an array. The simplest
> would be by carrying the last known observation forward.
> 0,0,10,8,0,0,7,0
> 0,0,10,8,8,8,7,7
> Or by somehow interpolating the missing values based on the previous
> and next known observations (mean).
> Thanks.


The functions `forward_fill` and `backward_fill` in scikits.timeseries  
should do what you want. They work also on MaskedArray objects,  
meaning that you don't need to have actual series.
The catch is that you need to install scikits.timeseries, of course.  
More info here:http://pytseries.sourceforge.net/


More information about the Numpy-discussion mailing list