Skip to content

Commit

Permalink
Update indexing unpacking logic for single block case (pandas-dev#56209)
Browse files Browse the repository at this point in the history
  • Loading branch information
phofl authored Nov 29, 2023
1 parent 0ae4dfd commit 0e8174f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,12 @@ def _setitem_single_block(self, indexer, value, name: str) -> None:
"""
from pandas import Series

if (isinstance(value, ABCSeries) and name != "iloc") or isinstance(value, dict):
# TODO(EA): ExtensionBlock.setitem this causes issues with
# setting for extensionarrays that store dicts. Need to decide
# if it's worth supporting that.
value = self._align_series(indexer, Series(value))

info_axis = self.obj._info_axis_number
item_labels = self.obj._get_axis(info_axis)
if isinstance(indexer, tuple):
Expand All @@ -2160,13 +2166,7 @@ def _setitem_single_block(self, indexer, value, name: str) -> None:

indexer = maybe_convert_ix(*indexer) # e.g. test_setitem_frame_align

if (isinstance(value, ABCSeries) and name != "iloc") or isinstance(value, dict):
# TODO(EA): ExtensionBlock.setitem this causes issues with
# setting for extensionarrays that store dicts. Need to decide
# if it's worth supporting that.
value = self._align_series(indexer, Series(value))

elif isinstance(value, ABCDataFrame) and name != "iloc":
if isinstance(value, ABCDataFrame) and name != "iloc":
value = self._align_frame(indexer, value)._values

# check for chained assignment
Expand Down

0 comments on commit 0e8174f

Please sign in to comment.