code: def interpolate_nans_1d(x, y, kind='linear'):
      x_sort_args = np.argsort(x)
      x = x[x_sort_args]
      y = y[x_sort_args]
      nans = np.isnan(y)
      if kind == 'linear':
          y[nans] = np.interp(x[nans], x[~nans], y[~nans])
      elif kind == 'log':
          y[nans] = np.interp(np.log(x[nans]), np.log(x[~nans]), y[~nans])
      else:
          raise ValueError('Unknown option for kind: {0}'.format(str(kind)))
      return y[x_sort_args]