Skip to content

TST: add test for indexing with single/double tuples #29448

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 9 commits into from
Nov 20, 2019
11 changes: 11 additions & 0 deletions pandas/tests/frame/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2626,6 +2626,17 @@ def test_index_namedtuple(self):
result = df.loc[IndexType("foo", "bar")]["A"]
assert result == 1

@pytest.mark.parametrize("tpl", [tuple([1]), tuple([1, 2])])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file moved to pandas/tests/frame/indexing/test_indexing.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, @jreback

def test_index_single_double_tuples(self, tpl):
# GH 20991
idx = pd.Index([tuple([1]), tuple([1, 2])], name="A", tupleize_cols=False)
df = DataFrame(index=idx)

result = df.loc[[tpl]]
idx = pd.Index([tpl], name="A", tupleize_cols=False)
expected = DataFrame(index=idx)
tm.assert_frame_equal(result, expected)

def test_boolean_indexing(self):
idx = list(range(3))
cols = ["A", "B", "C"]
Expand Down