Skip to content

Commit a62c896

Browse files
committed
Remove specifically handling
1 parent b227024 commit a62c896

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pandas/core/internals/blocks.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
PandasDtype,
7373
TimedeltaArray,
7474
)
75-
from pandas.core.arrays.string_ import StringDtype
7675
from pandas.core.base import PandasObject
7776
import pandas.core.common as com
7877
from pandas.core.construction import extract_array
@@ -1008,13 +1007,17 @@ def coerce_to_target_dtype(self, other):
10081007
# if we cannot then coerce to object
10091008
dtype, _ = infer_dtype_from(other, pandas_dtype=True)
10101009

1011-
if isinstance(self.dtype, StringDtype):
1012-
dtype = StringDtype()
1013-
10141010
if is_dtype_equal(self.dtype, dtype):
10151011
return self
10161012

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

0 commit comments

Comments
 (0)