Skip to content

Calling xs on DataFrame with index but no columns raises Exception #98

Closed
@wesm

Description

@wesm

example:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions