# Buggy code
def xs(self, key, axis=1, copy=True):
    from pandas.core.series import Series

    assert axis >= 1

    i = self.axes[axis].get_loc(key)
    slicer = [slice(None, None) for _ in range(self.ndim)]
    slicer[axis] = i
    slicer = tuple(slicer)

    new_axes = list(self.axes)
    new_axes.pop(axis)

    if len(self.blocks) > 1:
        if not copy:
            raise Exception(
                "cannot get view of mixed-type or non-consolidated DataFrame"
            )
        new_blocks = []
        for blk in self.blocks:
            newb = make_block(blk.values[slicer], blk.items, blk.ref_items)
            new_blocks.append(newb)
    else:
        vals = self.blocks[0].values[slicer]
        if copy:
            vals = vals.copy()
        new_blocks = [make_block(vals, self.items, self.items)]

    return BlockManager(new_blocks, new_axes)


# Traceback (IndexError)
In [1]: df = DataFrame(index=['a', 'b', 'c'])

In [2]: df.ix['a']
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/home/wesm/code/pandas/<ipython-input-2-6181dcf1ffea> in <module>()
----> 1 df.ix['a']

/home/wesm/code/pandas/pandas/core/indexing.pyc in __getitem__(self, key)
102             return self._fancy_getitem(key, axis=0)
103         else:
--> 104             return self._fancy_getitem_axis(key, axis=0)
105
106     def __setitem__(self, key, value):

/home/wesm/code/pandas/pandas/core/indexing.pyc in _fancy_getitem_axis(self, key, axis)
200                 return self.frame.xs(idx)
201             else:
--> 202                 return self.frame.xs(idx, copy=False)
203         else:
204             col = key

/home/wesm/code/pandas/pandas/core/frame.pyc in xs(self, key, copy)
839
840         self._consolidate_inplace()
--> 841         values = self._data.xs(key, axis=1, copy=copy)
842         return Series(values.as_matrix(), index=self.columns)
843

/home/wesm/code/pandas/pandas/core/internals.pyc in xs(self, key, axis, copy)
451                 new_blocks.append(newb)
452         else:
--> 453             vals = self.blocks[0].values[slicer]
454             if copy:
455                 vals = vals.copy()

IndexError: list index out of range

# Fixed code
def xs(self, key, axis=1, copy=True):
    assert axis >= 1

    i = self.axes[axis].get_loc(key)
    slicer = [slice(None, None) for _ in range(self.ndim)]
    slicer[axis] = i
    slicer = tuple(slicer)

    new_axes = list(self.axes)
    new_axes.pop(axis)

    new_blocks = []
    if len(self.blocks) > 1:
        if not copy:
            raise Exception(
                "cannot get view of mixed-type or non-consolidated DataFrame"
            )
        for blk in self.blocks:
            newb = make_block(blk.values[slicer], blk.items, blk.ref_items)
            new_blocks.append(newb)
    elif len(self.blocks) == 1:
        vals = self.blocks[0].values[slicer]
        if copy:
            vals = vals.copy()
        new_blocks = [make_block(vals, self.items, self.items)]

    return BlockManager(new_blocks, new_axes)