Skip to content

Fix regression for loc and __setitem__ when one-dimensional tuple was given for MultiIndex #37787

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 8 commits into from
Nov 14, 2020
Prev Previous commit
Next Next commit
Add new test
  • Loading branch information
phofl committed Nov 13, 2020
commit e3f90be43b0e64ed4b1b33e6c1ee6d43ec0357b6
9 changes: 9 additions & 0 deletions pandas/tests/indexing/multiindex/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ def test_multiindex_loc_one_dimensional_tuple(self, frame_or_series):
expected = frame_or_series([0, 2], index=mi)
tm.assert_equal(obj, expected)

@pytest.mark.parametrize("indexer", [('a',), ('a')])
def test_multiindex_one_dimensiona_tuple_columns(self, indexer):
Copy link
Member

Choose a reason for hiding this comment

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

typo dimensional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, thx. Fixed

# GH#37711
mi = MultiIndex.from_tuples([("a", "A"), ("b", "A")])
obj = DataFrame([1, 2], index=mi)
obj.loc[indexer, :] = 0
expected = DataFrame([0, 2], index=mi)
tm.assert_frame_equal(obj, expected)


@pytest.mark.parametrize(
"indexer, pos",
Expand Down