File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1165,7 +1165,10 @@ def coerce_to_target_dtype(self, other):
11651165 if is_dtype_equal (self .dtype , dtype ):
11661166 return self
11671167
1168- if self .is_bool or is_object_dtype (dtype ) or is_bool_dtype (dtype ):
1168+ if is_extension_array_dtype (self .dtype ) and not is_categorical_dtype (dtype ):
1169+ dtype = self .dtype
1170+
1171+ elif self .is_bool or is_object_dtype (dtype ) or is_bool_dtype (dtype ):
11691172 # we don't upcast to bool
11701173 return self .astype (object )
11711174
@@ -1209,6 +1212,9 @@ def coerce_to_target_dtype(self, other):
12091212 f"possible recursion in coerce_to_target_dtype: { self } { other } "
12101213 )
12111214
1215+ if is_categorical_dtype (dtype ) or self .is_datetime :
1216+ return self .astype (object )
1217+
12121218 try :
12131219 return self .astype (dtype )
12141220 except (ValueError , TypeError , OverflowError ):
You can’t perform that action at this time.
0 commit comments