[Numpy-discussion] Optimize removing nan-values of dataset
Wed Aug 14 10:49:32 CDT 2013
Yeah, interp is what you want. What you want to do with the end values is
up to you, but could be done like this:
ind = where(logical_not(np.isnan(y)))
y1 = interp(range(len(y)), ind, y[ind])
y1 = y1[ind:ind[-1]]
On Wed, Aug 14, 2013 at 4:38 AM, Thomas Goebel <
> * On 13/08/2013 23:32, David Reed wrote:
> > Hi Thomas,
> > Your array is Nx6 do you want the nan values replace by the
> > mean of the 2 adjacent elemets by row or by column?
> Hi David,
> i want it to be replaced by column.
> I also found numpy.interp but this function replaces all nan
> values at the beginning/end of array which should be omitted.
> As an example:
> y = np.array([nan, nan, 1, 2, 3, nan, nan, 4, nan, 5, nan, nan])
> nans = np.isnan(y)
> Only the values y[5:7] and y should be replaced. Is it
> possible to set nans[0:2] and nans[-2:] to False with something
> like nans.startswith nans.endswith?
> NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion