Multi-Index Slice Selection in Series · Issue #6018 · pandas-dev/pandas (original) (raw)

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) in () ----> 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