I get this error: ValueError: A value in x_new is below the interpolation range. I believe this is because the very 1st value is a nan. Anyone knows how can I get around this?

I am trying this:
y = np.array([float('nan'),2, float('nan'),4,float('nan'),5, float('nan'),float('nan'),11])
xnew = np.arange(len(y))

nan_idx = np.argwhere(np.isnan(y))
xold = np.delete(xnew,nan_idx)
yold = np.delete(y, nan_idx)

f = interp1d(xold,yold)

ynew = f(xnew)

 
And I get this error:
ValueError: A value in x_new is below the interpolation range.
I believe this is because the very 1st value is a nan. Anyone knows how can I get around this?
My data has nans in the very beginning and I am happy to drop that part of the data.
You already invited:

Diane

Upvotes from:

according to this SO article your solution may be with `fill_value='extrapolate' when initializing spi.interp1d`

If you wanna answer this question please Login or Register