[Numpy-discussion] Optimize removing nan-values of dataset
Wed Aug 14 03:38:38 CDT 2013
* 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?
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?
More information about the NumPy-Discussion