Skip to content

Commit 0dd5a1d

Browse files
committed
BUG: TypeError when attempting to replace Nullable integer data type with a float value (#45729)
BUG: Replacing pd.NA by None has no effect (#45601)
1 parent 2ff7dc0 commit 0dd5a1d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pandas/core/internals/blocks.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -692,13 +692,14 @@ def replace(
692692

693693
elif self._can_hold_element(value):
694694
blk = self if inplace else self.copy()
695+
blk = blk.to_native_types(value)
695696
putmask_inplace(blk.values, mask, value)
696-
if not (self.is_object and value is None):
697+
if blk.is_object and value is None:
697698
# if the user *explicitly* gave None, we keep None, otherwise
698699
# may downcast to NaN
699-
blocks = blk.convert(numeric=False, copy=False)
700-
else:
701700
blocks = [blk]
701+
else:
702+
blocks = blk.convert(numeric=False, copy=False)
702703
return blocks
703704

704705
elif self.ndim == 1 or self.shape[0] == 1:

0 commit comments

Comments
 (0)