Skip to content

Commit 38a5c83

Browse files
committed
Remove specifically handling
1 parent b227024 commit 38a5c83

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pandas/core/internals/blocks.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1008,13 +1008,17 @@ def coerce_to_target_dtype(self, other):
10081008
# if we cannot then coerce to object
10091009
dtype, _ = infer_dtype_from(other, pandas_dtype=True)
10101010

1011-
if isinstance(self.dtype, StringDtype):
1012-
dtype = StringDtype()
1013-
10141011
if is_dtype_equal(self.dtype, dtype):
10151012
return self
10161013

1017-
if self.is_bool or is_object_dtype(dtype) or is_bool_dtype(dtype):
1014+
if (
1015+
is_extension_array_dtype(self.dtype)
1016+
and not is_categorical_dtype(self.dtype)
1017+
and not self.is_datetime
1018+
):
1019+
dtype = self.dtype
1020+
1021+
elif self.is_bool or is_object_dtype(dtype) or is_bool_dtype(dtype):
10181022
# we don't upcast to bool
10191023
return self.astype(object)
10201024

0 commit comments

Comments
 (0)