File tree 1 file changed +7
-1
lines changed
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):
1165
1165
if is_dtype_equal (self .dtype , dtype ):
1166
1166
return self
1167
1167
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 ):
1169
1172
# we don't upcast to bool
1170
1173
return self .astype (object )
1171
1174
@@ -1209,6 +1212,9 @@ def coerce_to_target_dtype(self, other):
1209
1212
f"possible recursion in coerce_to_target_dtype: { self } { other } "
1210
1213
)
1211
1214
1215
+ if is_categorical_dtype (dtype ) or self .is_datetime :
1216
+ return self .astype (object )
1217
+
1212
1218
try :
1213
1219
return self .astype (dtype )
1214
1220
except (ValueError , TypeError , OverflowError ):
You can’t perform that action at this time.
0 commit comments