Skip to content

BUG: Bug in multi-axis indexing using .loc on non-unique indices (GH6504) #6506

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 1 commit into from
Feb 28, 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
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Bug Fixes
rest of pandas (:issue:`5129`).
- Bug in ``read_html`` tests where redirected invalid URLs would make one test
fail (:issue:`6445`).
- Bug in multi-axis indexing using ``.loc`` on non-unique indices (:issue:`6504`)

pandas 0.13.1
-------------
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,8 @@ def _multi_take_opportunity(self, tup):
return False
elif com._is_bool_indexer(indexer):
return False
elif not ax.is_unique:
return False

return True

Expand Down
15 changes: 15 additions & 0 deletions pandas/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,21 @@ def test_dups_fancy_indexing(self):
result = df.ix[:,['A','B','C']]
assert_frame_equal(result, expected)

# GH 6504, multi-axis indexing
df = DataFrame(np.random.randn(9,2), index=[1,1,1,2,2,2,3,3,3], columns=['a', 'b'])

expected = df.iloc[0:6]
result = df.loc[[1, 2]]
assert_frame_equal(result, expected)

expected = df
result = df.loc[:,['a', 'b']]
assert_frame_equal(result, expected)

expected = df.iloc[0:6,:]
result = df.loc[[1, 2], ['a', 'b']]
assert_frame_equal(result, expected)

def test_indexing_mixed_frame_bug(self):

# GH3492
Expand Down