# Buggy code
def insert(self, loc, item, value, allow_duplicates=False):
    """
    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

    """
    if not allow_duplicates and item in self.items:
        # Should this be a different kind of error??
        raise ValueError("cannot insert %s, already exists" % item)

    if not isinstance(loc, int):
        raise TypeError("loc must be int")

    # insert to the axis; this could possibly raise a TypeError
    new_axis = self.items.insert(loc, item)

    block = make_block(values=value, ndim=self.ndim, placement=slice(loc, loc + 1))

    for blkno, count in _fast_count_smallints(self._blknos[loc:]):
        blk = self.blocks[blkno]
        if count == len(blk.mgr_locs):
            blk.mgr_locs = blk.mgr_locs.add(1)
        else:
            new_mgr_locs = blk.mgr_locs.as_array.copy()
            new_mgr_locs[new_mgr_locs >= loc] += 1
            blk.mgr_locs = new_mgr_locs

    if loc == self._blklocs.shape[0]:
        # np.append is a lot faster (at least in numpy 1.7.1), let's use it
        # if we can.
        self._blklocs = np.append(self._blklocs, 0)
        self._blknos = np.append(self._blknos, len(self.blocks))
    else:
        self._blklocs = np.insert(self._blklocs, loc, 0)
        self._blknos = np.insert(self._blknos, loc, len(self.blocks))

    self.axes[0] = new_axis
    self.blocks += (block,)
    self._shape = None

    self._known_consolidated = False

    if len(self.blocks) > 100:
        self._consolidate_inplace()


# Traceback (TypeError)
In [2]: df = pd.DataFrame(index=range(2), columns=pd.MultiIndex.from_tuples([['A', 'a'], ['B', '']]))

In [3]: df.index.name = 'B'

In [4]: df.reset_index()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-6983677cc901> in <module>()
----> 1 df.reset_index()

/home/pietro/nobackup/repo/pandas/pandas/core/frame.py in reset_index(self, level, drop, inplace, col_level, col_fill)
3056                     name = tuple(name_lst)
3057             values = _maybe_casted_values(self.index)
-> 3058             new_obj.insert(0, name, values)
3059
3060         new_obj.index = new_index

/home/pietro/nobackup/repo/pandas/pandas/core/frame.py in insert(self, loc, column, value, allow_duplicates)
2517         value = self._sanitize_column(column, value, broadcast=False)
2518         self._data.insert(loc, column, value,
-> 2519                           allow_duplicates=allow_duplicates)
2520
2521     def assign(self, **kwargs):

/home/pietro/nobackup/repo/pandas/pandas/core/internals.py in insert(self, loc, item, value, allow_duplicates)
3808         if not allow_duplicates and item in self.items:
3809             # Should this be a different kind of error??
-> 3810             raise ValueError('cannot insert %s, already exists' % item)
3811
3812         if not isinstance(loc, int):

TypeError: not all arguments converted during string formatting

# Fixed code
def insert(self, loc, item, value, allow_duplicates=False):
    """
    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

    """
    if not allow_duplicates and item in self.items:
        # Should this be a different kind of error??
        raise ValueError("cannot insert {}, already exists".format(item))

    if not isinstance(loc, int):
        raise TypeError("loc must be int")

    # insert to the axis; this could possibly raise a TypeError
    new_axis = self.items.insert(loc, item)

    block = make_block(values=value, ndim=self.ndim, placement=slice(loc, loc + 1))

    for blkno, count in _fast_count_smallints(self._blknos[loc:]):
        blk = self.blocks[blkno]
        if count == len(blk.mgr_locs):
            blk.mgr_locs = blk.mgr_locs.add(1)
        else:
            new_mgr_locs = blk.mgr_locs.as_array.copy()
            new_mgr_locs[new_mgr_locs >= loc] += 1
            blk.mgr_locs = new_mgr_locs

    if loc == self._blklocs.shape[0]:
        # np.append is a lot faster (at least in numpy 1.7.1), let's use it
        # if we can.
        self._blklocs = np.append(self._blklocs, 0)
        self._blknos = np.append(self._blknos, len(self.blocks))
    else:
        self._blklocs = np.insert(self._blklocs, loc, 0)
        self._blknos = np.insert(self._blknos, loc, len(self.blocks))

    self.axes[0] = new_axis
    self.blocks += (block,)
    self._shape = None

    self._known_consolidated = False

    if len(self.blocks) > 100:
        self._consolidate_inplace()