We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2ff7dc0 commit 0dd5a1dCopy full SHA for 0dd5a1d
pandas/core/internals/blocks.py
@@ -692,13 +692,14 @@ def replace(
692
693
elif self._can_hold_element(value):
694
blk = self if inplace else self.copy()
695
+ blk = blk.to_native_types(value)
696
putmask_inplace(blk.values, mask, value)
- if not (self.is_object and value is None):
697
+ if blk.is_object and value is None:
698
# if the user *explicitly* gave None, we keep None, otherwise
699
# may downcast to NaN
- blocks = blk.convert(numeric=False, copy=False)
700
- else:
701
blocks = [blk]
+ else:
702
+ blocks = blk.convert(numeric=False, copy=False)
703
return blocks
704
705
elif self.ndim == 1 or self.shape[0] == 1:
0 commit comments