-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Regression in loc.setitem raising ValueError with unordered MultiIndex columns and scalar indexer #39071
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
Regression in loc.setitem raising ValueError with unordered MultiIndex columns and scalar indexer #39071
Changes from 1 commit
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 |
---|---|---|
|
@@ -1685,6 +1685,15 @@ def test_getitem_interval_index_partial_indexing(self): | |
res = df.loc[:, 0.5] | ||
tm.assert_series_equal(res, expected) | ||
|
||
@pytest.mark.parametrize("indexer", ["A", ["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 add the other 3 cases from OP that 'work fine' (2 x slice and a sorted case). ok to have another test if helpful. 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. Done, worked through parametrization |
||
def test_setitem_unsorted_multiindex_columns(self, indexer): | ||
# GH#38601 | ||
mi = MultiIndex.from_tuples([("A", 4), ("B", "3"), ("A", "2")]) | ||
df = DataFrame([[1, 2, 3], [4, 5, 6]], columns=mi) | ||
df.loc[:, indexer] = np.zeros((2, 2), dtype=int) | ||
expected = DataFrame([[0, 2, 0], [0, 5, 0]], columns=mi) | ||
tm.assert_frame_equal(df, expected) | ||
|
||
|
||
class TestDataFrameIndexingUInt64: | ||
def test_setitem(self, uint64_frame): | ||
|
Uh oh!
There was an error while loading. Please reload this page.