Skip to content

TST: partial indexing with __getitem__ and integer labels #16029

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
Apr 17, 2017
Merged
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
24 changes: 24 additions & 0 deletions pandas/tests/indexing/test_multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,30 @@ def test_loc_multiindex(self):
xp = mi_int.ix[4]
tm.assert_frame_equal(rs, xp)

def test_getitem_partial_int(self):
# GH 12416
# with single item
l1 = [10, 20]
l2 = ['a', 'b']
df = DataFrame(index=range(2),
columns=pd.MultiIndex.from_product([l1, l2]))
expected = DataFrame(index=range(2),
columns=l2)
result = df[20]
tm.assert_frame_equal(result, expected)

# with list
expected = DataFrame(index=range(2),
columns=pd.MultiIndex.from_product([l1[1:], l2]))
result = df[[20]]
tm.assert_frame_equal(result, expected)

# missing item:
with tm.assertRaisesRegexp(KeyError, '1'):
df[1]
with tm.assertRaisesRegexp(KeyError, "'\[1\] not in index'"):
df[[1]]

def test_loc_multiindex_indexer_none(self):

# GH6788
Expand Down