Skip to content

Commit 7ed1b83

Browse files
ganevgvproost
authored andcommitted
TST: add test for indexing with single/double tuples (pandas-dev#29448)
1 parent 015966c commit 7ed1b83

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/frame/indexing/test_indexing.py

+11
Original file line numberDiff line numberDiff line change
@@ -2624,6 +2624,17 @@ def test_index_namedtuple(self):
26242624
result = df.loc[IndexType("foo", "bar")]["A"]
26252625
assert result == 1
26262626

2627+
@pytest.mark.parametrize("tpl", [tuple([1]), tuple([1, 2])])
2628+
def test_index_single_double_tuples(self, tpl):
2629+
# GH 20991
2630+
idx = pd.Index([tuple([1]), tuple([1, 2])], name="A", tupleize_cols=False)
2631+
df = DataFrame(index=idx)
2632+
2633+
result = df.loc[[tpl]]
2634+
idx = pd.Index([tpl], name="A", tupleize_cols=False)
2635+
expected = DataFrame(index=idx)
2636+
tm.assert_frame_equal(result, expected)
2637+
26272638
def test_boolean_indexing(self):
26282639
idx = list(range(3))
26292640
cols = ["A", "B", "C"]

0 commit comments

Comments
 (0)