code: def filter(self, filters=None, keep=True, inplace=False, **kwargs):
          
          if filters is not None:
              msg = '`filters` keyword argument in `filter()` is deprecated ' + \
                  'and will be removed in the next release'
              warnings.warn(msg)
              kwargs.update(filters)
  
          _keep = self._apply_filters(**kwargs)
          _keep = _keep if keep else ~_keep
          ret = copy.deepcopy(self) if not inplace else self
          ret.data = ret.data[_keep]
  
          idx = _make_index(ret.data)
          if len(idx) == 0:
              logger().warning('Filtered IamDataFrame is empty!')
          ret.meta = ret.meta.loc[idx]
          if not inplace:
              return ret
docs: Return a filtered IamDataFrame (i.e., a subset of current data)
  
          Parameters
          ----------
          keep: bool, default True
              keep all scenarios satisfying the filters (if True) or the inverse
          inplace: bool, default False
              if True, do operation inplace and return None
          filters by kwargs or dict (deprecated):
              The following columns are available for filtering:
               - metadata columns: filter by category assignment
               - 'model', 'scenario', 'region', 'variable', 'unit':
                 string or list of strings, where `*` can be used as a wildcard
               - 'level': the maximum "depth" of IAM variables (number of '|')
                 (excluding the strings given in the 'variable' argument)
               - 'year': takes an integer, a list of integers or a range
                 note that the last year of a range is not included,
                 so `range(2010, 2015)` is interpreted as `[2010, ..., 2014]`
               - arguments for filtering by `datetime.datetime`
                 ('month', 'hour', 'time')
               - 'regexp=True' disables pseudo-regexp syntax in `pattern_match()`