-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix return of missing values when applying loc to single level of MultiIndex #37706
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 4 commits
855f710
a7a5092
f12c050
7ba80f1
80c022c
5c11442
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 |
---|---|---|
|
@@ -598,3 +598,19 @@ def test_getitem_loc_commutability(multiindex_year_month_day_dataframe_random_da | |
result = ser[2000, 5] | ||
expected = df.loc[2000, 5]["A"] | ||
tm.assert_series_equal(result, expected) | ||
|
||
|
||
def test_loc_with_nan(): | ||
# GH: 27104 | ||
df = DataFrame( | ||
{"col": [1, 2, 5], "ind1": ["a", "d", np.nan], "ind2": [1, 4, 5]} | ||
).set_index(["ind1", "ind2"]) | ||
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 also select 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. Parametrization would be ugly, because Index needs new definition. Added the test below. 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. kk totally fine, i always ask, but like you did push back if its non-trivial or would make it less obvious. |
||
result = df.loc[["a"]] | ||
expected = DataFrame( | ||
{"col": [1]}, index=MultiIndex.from_tuples([("a", 1)], names=["ind1", "ind2"]) | ||
) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
result = df.loc["a"] | ||
expected = DataFrame({"col": [1]}, index=Index([1], name="ind2")) | ||
tm.assert_frame_equal(result, expected) |
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.
seems there is a
>>>>>>> master
?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.
Looks like merge went wrong. Is fixed now. Thanks