-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Changes from 2 commits
76f58fc
039c18a
12a8e20
24e7c1f
4cfab61
acafc9e
9652128
a14d23d
2e38564
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2626,6 +2626,20 @@ def test_index_namedtuple(self): | |
result = df.loc[IndexType("foo", "bar")]["A"] | ||
assert result == 1 | ||
|
||
def test_index_single_double_tuples(self): | ||
# GH 20991 | ||
tuple_1 = tuple([1, 2]) | ||
tuple_2 = tuple([1]) | ||
df = DataFrame([[tuple_1], [tuple_2]], columns=["A"]).set_index("A") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you just construct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @WillAyd - removed |
||
|
||
result = df.loc[[df.index[0]]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @WillAyd - removed |
||
expected = DataFrame([[tuple_1]], columns=["A"]).set_index("A") | ||
tm.assert_frame_equal(result, expected) | ||
|
||
result = df.loc[[df.index[1]]] | ||
expected = DataFrame([[tuple_2]], columns=["A"]).set_index("A") | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_boolean_indexing(self): | ||
idx = list(range(3)) | ||
cols = ["A", "B", "C"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can parameterize this (e.g. pass in what you have as tuple_1, tuple_2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the feedback @jreback - now using parameterize