@@ -1170,21 +1170,26 @@ def dispatch_to_extension_op(op, left, right):
1170
1170
# we need to listify to avoid ndarray, or non-same-type extension array
1171
1171
# dispatching
1172
1172
1173
+ new_type = left_type = right_type = None
1173
1174
if is_extension_array_dtype (left ):
1174
1175
1176
+ left_type = left .dtype .type
1175
1177
new_left = left .values
1176
1178
if isinstance (right , np .ndarray ):
1177
1179
1178
1180
# handle numpy scalars, this is a PITA
1179
1181
# TODO(jreback)
1180
1182
new_right = lib .item_from_zerodim (right )
1183
+ right_type = new_right .dtype
1181
1184
if is_scalar (new_right ):
1182
1185
new_right = [new_right ]
1183
1186
new_right = list (new_right )
1184
1187
elif is_extension_array_dtype (right ) and type (left ) != type (right ):
1188
+ right_type = new_right .dtype .type
1185
1189
new_right = list (new_right )
1186
1190
else :
1187
1191
new_right = right
1192
+ right_type = type (right )
1188
1193
1189
1194
else :
1190
1195
@@ -1193,12 +1198,17 @@ def dispatch_to_extension_op(op, left, right):
1193
1198
1194
1199
res_values = op (new_left , new_right )
1195
1200
res_name = get_op_result_name (left , right )
1196
-
1201
+ if right_type and left_type :
1202
+ new_type = find_common_type ([right_type , left_type ])
1197
1203
if op .__name__ == 'divmod' :
1198
1204
return _construct_divmod_result (
1199
1205
left , res_values , left .index , res_name )
1200
1206
1201
- return _construct_result (left , res_values , left .index , res_name )
1207
+ result = _construct_result (left , res_values , left .index , res_name )
1208
+ if is_object_dtype (result .dtype ):
1209
+ result = _construct_result (left , res_values , left .index , res_name ,
1210
+ new_type )
1211
+ return result
1202
1212
1203
1213
1204
1214
def _arith_method_SERIES (cls , op , special ):
0 commit comments