Skip to content

Commit 7f4e22d

Browse files
Damian BarabonkovDamian Barabonkov
Damian Barabonkov
authored and
Damian Barabonkov
committed
Fixed bug with setting a Series and the consistency of the column type. Issue: #pandas-dev#43996
1 parent 8022743 commit 7f4e22d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

pandas/core/indexing.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1817,8 +1817,7 @@ def _setitem_single_column(self, loc: int, value, plane_indexer):
18171817
if com.is_null_slice(pi) or com.is_full_slice(pi, len(self.obj)):
18181818
ser = value
18191819
elif is_array_like(value) and is_exact_shape_match(ser, value):
1820-
ser = value
1821-
1820+
ser.update(value)
18221821
else:
18231822
# set the item, possibly having a dtype change
18241823
ser = ser.copy()

pandas/core/internals/blocks.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -924,11 +924,11 @@ def setitem(self, indexer, value):
924924
# otherwise should have _can_hold_element
925925

926926
return self.astype(dtype).setitem(indexer, value)
927-
928-
if self.dtype.kind in ["m", "M"]:
929-
arr = self.array_values().T
930-
arr[indexer] = value
931-
return self
927+
else:
928+
if self.dtype.kind in ["m", "M"]:
929+
arr = self.array_values().T
930+
arr[indexer] = value
931+
return self
932932

933933
# value must be storable at this moment
934934
if is_extension_array_dtype(getattr(value, "dtype", None)):

0 commit comments

Comments
 (0)