We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b227024 commit 2844c80Copy full SHA for 2844c80
pandas/core/internals/blocks.py
@@ -1008,13 +1008,17 @@ def coerce_to_target_dtype(self, other):
1008
# if we cannot then coerce to object
1009
dtype, _ = infer_dtype_from(other, pandas_dtype=True)
1010
1011
- if isinstance(self.dtype, StringDtype):
1012
- dtype = StringDtype()
1013
-
1014
if is_dtype_equal(self.dtype, dtype):
1015
return self
1016
1017
- if self.is_bool or is_object_dtype(dtype) or is_bool_dtype(dtype):
+ if (
+ is_extension_array_dtype(self.dtype)
+ and not self.is_datetime
+ and not is_integer_dtype(dtype)
1018
+ ):
1019
+ dtype = self.dtype
1020
+
1021
+ elif self.is_bool or is_object_dtype(dtype) or is_bool_dtype(dtype):
1022
# we don't upcast to bool
1023
return self.astype(object)
1024
0 commit comments