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)))[0] y1 = interp(range(len(y)), ind, y[ind]) y1 = y1[ind[0]:ind[-1]] On Wed, Aug 14, 2013 at 4:38 AM, Thomas Goebel < [email protected]> wrote: > * 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[8] 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 > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
