diff --git a/doc/source/v0.14.1.txt b/doc/source/v0.14.1.txt index 586e47ff4f303..1c564fbf76f59 100644 --- a/doc/source/v0.14.1.txt +++ b/doc/source/v0.14.1.txt @@ -164,11 +164,6 @@ Bug Fixes -- Bug in ``.ix`` getitem should always return a Series (:issue:`7150`) - - - - @@ -216,3 +211,6 @@ Bug Fixes (:issue:`7366`). - Bug where ``NDFrame.replace()`` didn't correctly replace objects with ``Period`` values (:issue:`7379`). +- Bug in ``.ix`` getitem should always return a Series (:issue:`7150`) +- Bug in multi-index slicing with incomplete indexers (:issue:`7399`) +- Bug in multi-index slicing with a step in a sliced level (:issue:`7400`) diff --git a/pandas/core/index.py b/pandas/core/index.py index fbadd92c1329c..69edf8d9c3f42 100644 --- a/pandas/core/index.py +++ b/pandas/core/index.py @@ -3526,11 +3526,11 @@ def _get_level_indexer(self, key, level=0): # handle a slice, returnig a slice if we can # otherwise a boolean indexer - start = level_index.get_loc(key.start) - stop = level_index.get_loc(key.stop) + start = level_index.get_loc(key.start or 0) + stop = level_index.get_loc(key.stop or len(level_index)-1) step = key.step - if level > 0 or self.lexsort_depth == 0: + if level > 0 or self.lexsort_depth == 0 or step is not None: # need to have like semantics here to right # searching as when we are using a slice # so include the stop+1 (so we include stop) diff --git a/pandas/tests/test_indexing.py b/pandas/tests/test_indexing.py index 7610ccc6cdf73..1945236f4efe8 100644 --- a/pandas/tests/test_indexing.py +++ b/pandas/tests/test_indexing.py @@ -1325,6 +1325,29 @@ def test_loc_multiindex(self): result = df.loc[[1,2]] assert_frame_equal(result, expected) + # GH 7399 + # incomplete indexers + s = pd.Series(np.arange(15,dtype='int64'),MultiIndex.from_product([range(5), ['a', 'b', 'c']])) + expected = s.loc[:, 'a':'c'] + + result = s.loc[0:4, 'a':'c'] + assert_series_equal(result, expected) + assert_series_equal(result, expected) + + result = s.loc[:4, 'a':'c'] + assert_series_equal(result, expected) + assert_series_equal(result, expected) + + result = s.loc[0:, 'a':'c'] + assert_series_equal(result, expected) + assert_series_equal(result, expected) + + # GH 7400 + # multiindexer gettitem with list of indexers skips wrong element + s = pd.Series(np.arange(15,dtype='int64'),MultiIndex.from_product([range(5), ['a', 'b', 'c']])) + expected = s.iloc[[6,7,8,12,13,14]] + result = s.loc[2:4:2, 'a':'c'] + assert_series_equal(result, expected) def test_series_getitem_multiindex(self):