Skip to content

BUG: set value with iloc and list like indexer #37041

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,9 @@ def _setitem_single_column(self, loc: int, value, plane_indexer):
else:
# set the item, possibly having a dtype change
ser = ser.copy()
if is_list_like(value):
if len(value) == 1:
value = value[0]
ser._mgr = ser._mgr.setitem(indexer=pi, value=value)
ser._maybe_update_cacher(clear=True)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ def setitem(self, indexer, value):
# value must be storable at this moment
if is_extension_array_dtype(getattr(value, "dtype", None)):
# We need to be careful not to allow through strings that
# can be parsed to EADtypes
# can be parsed to EADtypes
is_ea_value = True
arr_value = value
else:
Expand Down