code: def fill_series(x, year):
      
      x = x.dropna()
      if year in x.index and not np.isnan(x[year]):
          return x[year]
      else:
          prev = [i for i in x.index if i < year]
          nxt = [i for i in x.index if i > year]
          if prev and nxt:
              p = max(prev)
              n = min(nxt)
              return ((n - year) * x[p] + (year - p) * x[n]) / (n - p)
          else:
              return np.nan
docs: Returns the value of a timeseries (indexed over years) for a year
      by linear interpolation.
  
      Parameters
      ----------
      x: pandas.Series
          a timeseries to be interpolated
      year: int
          year of interpolation