Skip to content

Commit 0e8174f

Browse files
authored
Update indexing unpacking logic for single block case (pandas-dev#56209)
1 parent 0ae4dfd commit 0e8174f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pandas/core/indexing.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,12 @@ def _setitem_single_block(self, indexer, value, name: str) -> None:
21402140
"""
21412141
from pandas import Series
21422142

2143+
if (isinstance(value, ABCSeries) and name != "iloc") or isinstance(value, dict):
2144+
# TODO(EA): ExtensionBlock.setitem this causes issues with
2145+
# setting for extensionarrays that store dicts. Need to decide
2146+
# if it's worth supporting that.
2147+
value = self._align_series(indexer, Series(value))
2148+
21432149
info_axis = self.obj._info_axis_number
21442150
item_labels = self.obj._get_axis(info_axis)
21452151
if isinstance(indexer, tuple):
@@ -2160,13 +2166,7 @@ def _setitem_single_block(self, indexer, value, name: str) -> None:
21602166

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

2163-
if (isinstance(value, ABCSeries) and name != "iloc") or isinstance(value, dict):
2164-
# TODO(EA): ExtensionBlock.setitem this causes issues with
2165-
# setting for extensionarrays that store dicts. Need to decide
2166-
# if it's worth supporting that.
2167-
value = self._align_series(indexer, Series(value))
2168-
2169-
elif isinstance(value, ABCDataFrame) and name != "iloc":
2169+
if isinstance(value, ABCDataFrame) and name != "iloc":
21702170
value = self._align_frame(indexer, value)._values
21712171

21722172
# check for chained assignment

0 commit comments

Comments
 (0)