def insert(self, loc, item, value, allow_duplicates=False):
if not allow_duplicates and item in self.items:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(item))<EOL><DEDENT>if not isinstance(loc, int):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>new_axis = self.items.insert(loc, item)<EOL>block = make_block(values=value, ndim=self.ndim,<EOL>placement=slice(loc, loc + <NUM_LIT:1>))<EOL>for blkno, count in _fast_count_smallints(self._blknos[loc:]):<EOL><INDENT>blk = self.blocks[blkno]<EOL>if count == len(blk.mgr_locs):<EOL><INDENT>blk.mgr_locs = blk.mgr_locs.add(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>new_mgr_locs = blk.mgr_locs.as_array.copy()<EOL>new_mgr_locs[new_mgr_locs >= loc] += <NUM_LIT:1><EOL>blk.mgr_locs = new_mgr_locs<EOL><DEDENT><DEDENT>if loc == self._blklocs.shape[<NUM_LIT:0>]:<EOL><INDENT>self._blklocs = np.append(self._blklocs, <NUM_LIT:0>)<EOL>self._blknos = np.append(self._blknos, len(self.blocks))<EOL><DEDENT>else:<EOL><INDENT>self._blklocs = np.insert(self._blklocs, loc, <NUM_LIT:0>)<EOL>self._blknos = np.insert(self._blknos, loc, len(self.blocks))<EOL><DEDENT>self.axes[<NUM_LIT:0>] = new_axis<EOL>self.blocks += (block,)<EOL>self._shape = None<EOL>self._known_consolidated = False<EOL>if len(self.blocks) > <NUM_LIT:100>:<EOL><INDENT>self._consolidate_inplace()<EOL><DEDENT>
Insert item at selected position.

Parameters
----------
loc : int
item : hashable
value : array_like
allow_duplicates: bool
    If False, trying to insert non-unique item will raise