Skip to content

BUG: mi indexing bugs (GH7399,GH7400) #7404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions doc/source/v0.14.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ Bug Fixes



- Bug in ``.ix`` getitem should always return a Series (:issue:`7150`)







Expand Down Expand Up @@ -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`)
6 changes: 3 additions & 3 deletions pandas/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions pandas/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down