def insert(self, loc, item):
<EOL>if not isinstance(item, tuple):<EOL><INDENT>item = (item, ) + ('<STR_LIT>', ) * (self.nlevels - <NUM_LIT:1>)<EOL><DEDENT>elif len(item) != self.nlevels:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>new_levels = []<EOL>new_codes = []<EOL>for k, level, level_codes in zip(item, self.levels, self.codes):<EOL><INDENT>if k not in level:<EOL><INDENT>lev_loc = len(level)<EOL>level = level.insert(lev_loc, k)<EOL><DEDENT>else:<EOL><INDENT>lev_loc = level.get_loc(k)<EOL><DEDENT>new_levels.append(level)<EOL>new_codes.append(np.insert(<EOL>ensure_int64(level_codes), loc, lev_loc))<EOL><DEDENT>return MultiIndex(levels=new_levels, codes=new_codes,<EOL>names=self.names, verify_integrity=False)<EOL>
Make new MultiIndex inserting new item at location

Parameters
----------
loc : int
item : tuple
    Must be same length as number of levels in the MultiIndex

Returns
-------
new_index : Index