code: def require_variable(df, variable, unit=None, year=None, exclude_on_fail=False,
                       **kwargs):
      
      fdf = df.filter(**kwargs)
      if len(fdf.data) > 0:
          vdf = fdf.require_variable(variable=variable, unit=unit, year=year,
                                     exclude_on_fail=exclude_on_fail)
          df.meta['exclude'] |= fdf.meta['exclude']  # update if any excluded
          return vdf
docs: Check whether all scenarios have a required variable
  
      Parameters
      ----------
      df: IamDataFrame instance
      args: see `IamDataFrame.require_variable()` for details
      kwargs: passed to `df.filter()`