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 @@ -1130,7 +1130,10 @@ def coerce_to_target_dtype(self, other):
11301130 if is_dtype_equal (self .dtype , dtype ):
11311131 return self
11321132
1133- if self .is_bool or is_object_dtype (dtype ) or is_bool_dtype (dtype ):
1133+ if is_extension_array_dtype (self .dtype ) and not is_categorical_dtype (dtype ):
1134+ dtype = self .dtype
1135+
1136+ elif self .is_bool or is_object_dtype (dtype ) or is_bool_dtype (dtype ):
11341137 # we don't upcast to bool
11351138 return self .astype (object )
11361139
@@ -1174,6 +1177,9 @@ def coerce_to_target_dtype(self, other):
11741177 f"possible recursion in coerce_to_target_dtype: { self } { other } "
11751178 )
11761179
1180+ if is_categorical_dtype (dtype ) or self .is_datetime :
1181+ return self .astype (object )
1182+
11771183 try :
11781184 return self .astype (dtype )
11791185 except (ValueError , TypeError , OverflowError ):
You can’t perform that action at this time.
0 commit comments