def insert(self, loc, item):
<EOL>if _is_convertible_to_td(item):<EOL><INDENT>try:<EOL><INDENT>item = Timedelta(item)<EOL><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>elif is_scalar(item) and isna(item):<EOL><INDENT>item = self._na_value<EOL><DEDENT>freq = None<EOL>if isinstance(item, Timedelta) or (is_scalar(item) and isna(item)):<EOL><INDENT>if 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 = Timedelta(item).asm8.view(_TD_DTYPE)<EOL><DEDENT>try:<EOL><INDENT>new_tds = np.concatenate((self[:loc].asi8, [item.view(np.int64)],<EOL>self[loc:].asi8))<EOL>return self._shallow_copy(new_tds, 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