Skip to content

BUG: iloc raising for ea and null slice and length one list #48016

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 3 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,9 @@ def _unwrap_setitem_indexer(self, indexer):
elif com.is_null_slice(indexer[1]):
indexer = indexer[0]

elif is_list_like(indexer[1]) and indexer[1][0] == 0:
indexer = indexer[0]

else:
raise NotImplementedError(
"This should not be reached. Please report a bug at "
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,14 @@ def test_iloc_setitem_string_na(self, val):
expected = DataFrame({"a": [pd.NA, "b", "c"]}, dtype="string")
tm.assert_frame_equal(df, expected)

@pytest.mark.parametrize("func", [list, Series, np.array])
def test_iloc_setitem_ea_null_slice_length_one_list(self, func):
# GH#48016
df = DataFrame({"a": [1, 2, 3]}, dtype="Int64")
df.iloc[:, func([0])] = 5
expected = DataFrame({"a": [5, 5, 5]}, dtype="Int64")
tm.assert_frame_equal(df, expected)


class TestDataFrameIndexingUInt64:
def test_setitem(self, uint64_frame):
Expand Down