<div dir="ltr">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:<div><br></div><div><div>ind = where(logical_not(np.isnan(y)))[0]</div><div>y1 = interp(range(len(y)), ind, y[ind])</div>

<div>y1 = y1[ind[0]:ind[-1]]</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 14, 2013 at 4:38 AM, Thomas Goebel <span dir="ltr"><<a href="mailto:Thomas.Goebel@th-nuernberg.de" target="_blank">Thomas.Goebel@th-nuernberg.de</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">* On 13/08/2013 23:32, David Reed wrote:<br>
> Hi Thomas,<br>
><br>
> Your array is Nx6 do you want the nan values replace by the<br>
> mean of the 2 adjacent elemets by row or by column?<br>
<br>
</div>Hi David,<br>
<br>
i want it to be replaced by column.<br>
<br>
<br>
I also found numpy.interp but this function replaces all nan<br>
values at the beginning/end of array which should be omitted.<br>
<br>
As an example:<br>
y = np.array([nan, nan, 1, 2, 3, nan, nan, 4, nan, 5, nan, nan])<br>
nans = np.isnan(y)<br>
<br>
Only the values y[5:7] and y[8] should be replaced. Is it<br>
possible to set nans[0:2] and nans[-2:] to False with something<br>
like nans.startswith nans.endswith?<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br></div>