Skip to content

Multi-Index Slice Selection in Series #6018

Closed
@theandygross

Description

@theandygross

Slicing in Series with MultiIndex does not seem to work on master with .ix or .loc. This is not comparable with previous versions.

In [54]:  

s = pd.Series([1,2,3])
s.index = pd.MultiIndex.from_tuples([(0,0),(1,1), (2,1)])
s[:,0]

Out[55]:  

1    2
2    3

In [56]:  

s.ix[:,1]


IndexingError                             

Traceback (most recent call last)
<ipython-input-56-3163789d3245> in <module>()
----> 1 s.ix[:,1]

/cellar/users/agross/anaconda2/lib/python2.7/site-packages/pandas-0.13.0_120_gdd89ce4-py2.7-linux-x86_64.egg/pandas/core/indexing.pyc in __getitem__(self, key)
     52                 pass
     53 
---> 54             return self._getitem_tuple(key)
     55         else:
     56             return self._getitem_axis(key, axis=0)

/cellar/users/agross/anaconda2/lib/python2.7/site-packages/pandas-0.13.0_120_gdd89ce4-py2.7-linux-x86_64.egg/pandas/core/indexing.pyc in _getitem_tuple(self, tup)
    593 
    594         # no multi-index, so validate all of the indexers
--> 595         self._has_valid_tuple(tup)
    596 
    597         # ugly hack for GH #836

/cellar/users/agross/anaconda2/lib/python2.7/site-packages/pandas-0.13.0_120_gdd89ce4-py2.7-linux-x86_64.egg/pandas/core/indexing.pyc in _has_valid_tuple(self, key)
    103         for i, k in enumerate(key):
    104             if i >= self.obj.ndim:
--> 105                 raise IndexingError('Too many indexers')
    106             if not self._has_valid_type(k, i):
    107                 raise ValueError("Location based indexing can only have [%s] "

IndexingError: Too many indexers

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions