@@ -1013,6 +1013,11 @@ def coerce_to_target_dtype(self, other):
1013
1013
# we don't upcast to bool
1014
1014
return self .astype (object )
1015
1015
1016
+ elif ((self .is_float or self .is_complex ) and
1017
+ (is_integer_dtype (dtype ) or is_float_dtype (dtype ))):
1018
+ # don't coerce float/complex to int
1019
+ return self
1020
+
1016
1021
elif (self .is_datetime or
1017
1022
is_datetime64_dtype (dtype ) or
1018
1023
is_datetime64tz_dtype (dtype )):
@@ -3404,16 +3409,6 @@ def comp(s):
3404
3409
return isnull (values )
3405
3410
return _maybe_compare (values , getattr (s , 'asm8' , s ), operator .eq )
3406
3411
3407
- def _cast_scalar (block , scalar ):
3408
- dtype , val = infer_dtype_from_scalar (scalar , pandas_dtype = True )
3409
- if not is_dtype_equal (block .dtype , dtype ):
3410
- dtype = find_common_type ([block .dtype , dtype ])
3411
- block = block .astype (dtype )
3412
- # use original value
3413
- val = scalar
3414
-
3415
- return block , val
3416
-
3417
3412
masks = [comp (s ) for i , s in enumerate (src_list )]
3418
3413
3419
3414
result_blocks = []
@@ -3436,8 +3431,8 @@ def _cast_scalar(block, scalar):
3436
3431
# particular block
3437
3432
m = masks [i ][b .mgr_locs .indexer ]
3438
3433
if m .any ():
3439
- b , val = _cast_scalar ( b , d )
3440
- new_rb .extend (b .putmask (m , val , inplace = True ))
3434
+ b = b . coerce_to_target_dtype ( d )
3435
+ new_rb .extend (b .putmask (m , d , inplace = True ))
3441
3436
else :
3442
3437
new_rb .append (b )
3443
3438
rb = new_rb
0 commit comments