Replacing by nan:
A = np.array([1,3,5,-999,3,1,6,8,-999,-999,-999,3,5,7.])
A[A==-999] = np.nan
results in:
array([ 1., 3., 5., nan, 3., 1., 6., 8., nan, nan, nan, 3., 5., 7.])
If instead of that, you want to take the mean of the numbers left and right of the -999values:
A = np.array([1,3,5,-999,3,1,6,8,-999,-999,-999,3,5,7.])
A[A==-999] = np.nan
mask = np.isnan(A)
A[mask] = np.interp(np.flatnonzero(mask), np.flatnonzero(~mask), A[~mask])
results in:
array([ 1. , 3. , 5. , 4. , 3. , 1. , 6. , 8. , 6.75, 5.5 , 4.25, 3. , 5. , 7. ])