def insert(self, loc, item):
if is_scalar(item) and isna(item):<EOL><INDENT>item = self._na_value<EOL><DEDENT>freq = None<EOL>if isinstance(item, (datetime, np.datetime64)):<EOL><INDENT>self._assert_can_do_op(item)<EOL>if not self._has_same_tz(item) and not isna(item):<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>')<EOL><DEDENT>if self.size and self.freq is not None:<EOL><INDENT>if ((loc == <NUM_LIT:0> or loc == -len(self)) and<EOL>item + self.freq == self[<NUM_LIT:0>]):<EOL><INDENT>freq = self.freq<EOL><DEDENT>elif (loc == len(self)) and item - self.freq == self[-<NUM_LIT:1>]:<EOL><INDENT>freq = self.freq<EOL><DEDENT><DEDENT>item = _to_M8(item, tz=self.tz)<EOL><DEDENT>try:<EOL><INDENT>new_dates = np.concatenate((self[:loc].asi8, [item.view(np.int64)],<EOL>self[loc:].asi8))<EOL>return self._shallow_copy(new_dates, freq=freq)<EOL><DEDENT>except (AttributeError, TypeError):<EOL><INDENT>if isinstance(item, str):<EOL><INDENT>return self.astype(object).insert(loc, item)<EOL><DEDENT>raise TypeError(<EOL>"<STR_LIT>")<EOL><DEDENT>
Make new Index inserting new item at location

Parameters
----------
loc : int
item : object
    if not either a Python datetime or a numpy integer-like, returned
    Index dtype will be object rather than datetime.

Returns
-------
new_index : Index