@@ -1139,21 +1139,26 @@ def dispatch_to_extension_op(op, left, right):
1139
1139
# we need to listify to avoid ndarray, or non-same-type extension array
1140
1140
# dispatching
1141
1141
1142
+ new_type = left_type = right_type = None
1142
1143
if is_extension_array_dtype (left ):
1143
1144
1145
+ left_type = left .dtype .type
1144
1146
new_left = left .values
1145
1147
if isinstance (right , np .ndarray ):
1146
1148
1147
1149
# handle numpy scalars, this is a PITA
1148
1150
# TODO(jreback)
1149
1151
new_right = lib .item_from_zerodim (right )
1152
+ right_type = new_right .dtype
1150
1153
if is_scalar (new_right ):
1151
1154
new_right = [new_right ]
1152
1155
new_right = list (new_right )
1153
1156
elif is_extension_array_dtype (right ) and type (left ) != type (right ):
1157
+ right_type = new_right .dtype .type
1154
1158
new_right = list (new_right )
1155
1159
else :
1156
1160
new_right = right
1161
+ right_type = type (right )
1157
1162
1158
1163
else :
1159
1164
@@ -1162,12 +1167,17 @@ def dispatch_to_extension_op(op, left, right):
1162
1167
1163
1168
res_values = op (new_left , new_right )
1164
1169
res_name = get_op_result_name (left , right )
1165
-
1170
+ if right_type and left_type :
1171
+ new_type = find_common_type ([right_type , left_type ])
1166
1172
if op .__name__ == 'divmod' :
1167
1173
return _construct_divmod_result (
1168
1174
left , res_values , left .index , res_name )
1169
1175
1170
- return _construct_result (left , res_values , left .index , res_name )
1176
+ result = _construct_result (left , res_values , left .index , res_name )
1177
+ if is_object_dtype (result .dtype ):
1178
+ result = _construct_result (left , res_values , left .index , res_name ,
1179
+ new_type )
1180
+ return result
1171
1181
1172
1182
1173
1183
def _arith_method_SERIES (cls , op , special ):
0 commit comments