def func_interpolate_na(interpolator, x, y, **kwargs):
    '''helper function to apply interpolation along 1 dimension'''
    # it would be nice if this wasn't necessary, works around:
    # "ValueError: assignment destination is read-only" in assignment below
    out = y.copy()

    nans = pd.isnull(y)
    nonans = ~nans

    # fast track for no-nans and all-nans cases
    n_nans = nans.sum()
    if n_nans == 0 or n_nans == len(y):
        return y

    f = interpolator(x[nonans], y[nonans], **kwargs)
    out[nans] = f(x[nans])
    return out
def func_interpolate_na ( interpolator , x , y , ** kwargs ) : out = y . copy ( ) nans = pd . isnull ( y ) nonans = ~ nans n_nans = nans . sum ( ) if n_nans == 0 or n_nans == len ( y ) : return y f = interpolator ( x [ nonans ] , y [ nonans ] , ** kwargs ) out [ nans ] = f ( x [ nans ] ) return out
helper function to apply interpolation along 1 dimension