File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 72
72
PandasDtype ,
73
73
TimedeltaArray ,
74
74
)
75
- from pandas .core .arrays .string_ import StringDtype
76
75
from pandas .core .base import PandasObject
77
76
import pandas .core .common as com
78
77
from pandas .core .construction import extract_array
@@ -1008,13 +1007,17 @@ def coerce_to_target_dtype(self, other):
1008
1007
# if we cannot then coerce to object
1009
1008
dtype , _ = infer_dtype_from (other , pandas_dtype = True )
1010
1009
1011
- if isinstance (self .dtype , StringDtype ):
1012
- dtype = StringDtype ()
1013
-
1014
1010
if is_dtype_equal (self .dtype , dtype ):
1015
1011
return self
1016
1012
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 ):
1018
1021
# we don't upcast to bool
1019
1022
return self .astype (object )
1020
1023
You can’t perform that action at this time.
0 commit comments