def droplevel(self, level=<NUM_LIT:0>):
if not isinstance(level, (tuple, list)):<EOL><INDENT>level = [level]<EOL><DEDENT>levnums = sorted(self._get_level_number(lev) for lev in level)[::-<NUM_LIT:1>]<EOL>if len(level) == <NUM_LIT:0>:<EOL><INDENT>return self<EOL><DEDENT>if len(level) >= self.nlevels:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(len(level), self.nlevels))<EOL><DEDENT>new_levels = list(self.levels)<EOL>new_codes = list(self.codes)<EOL>new_names = list(self.names)<EOL>for i in levnums:<EOL><INDENT>new_levels.pop(i)<EOL>new_codes.pop(i)<EOL>new_names.pop(i)<EOL><DEDENT>if len(new_levels) == <NUM_LIT:1>:<EOL><INDENT>mask = new_codes[<NUM_LIT:0>] == -<NUM_LIT:1><EOL>result = new_levels[<NUM_LIT:0>].take(new_codes[<NUM_LIT:0>])<EOL>if mask.any():<EOL><INDENT>result = result.putmask(mask, np.nan)<EOL><DEDENT>result.name = new_names[<NUM_LIT:0>]<EOL>return result<EOL><DEDENT>else:<EOL><INDENT>from .multi import MultiIndex<EOL>return MultiIndex(levels=new_levels, codes=new_codes,<EOL>names=new_names, verify_integrity=False)<EOL><DEDENT>
Return index with requested level(s) removed.

If resulting index has only 1 level left, the result will be
of Index type, not MultiIndex.

.. versionadded:: 0.23.1 (support for non-MultiIndex)

Parameters
----------
level : int, str, or list-like, default 0
    If a string is given, must be the name of a level
    If list-like, elements must be names or indexes of levels.

Returns
-------
Index or MultiIndex