@@ -1051,7 +1051,7 @@ def f(m, v, i):
1051
1051
1052
1052
return [self .make_block (new_values )]
1053
1053
1054
- def coerce_to_target_dtype (self , other ):
1054
+ def coerce_to_target_dtype (self , other , force_coericion = False ):
1055
1055
"""
1056
1056
coerce the current block to a dtype compat for other
1057
1057
we will return a block, possibly object, and not raise
@@ -1067,7 +1067,7 @@ def coerce_to_target_dtype(self, other):
1067
1067
return self
1068
1068
1069
1069
if self .is_bool or is_object_dtype (dtype ) or is_bool_dtype (dtype ):
1070
- if is_float_dtype (dtype ) or is_integer_dtype (dtype ):
1070
+ if force_coericion and is_float_dtype (dtype ) or is_integer_dtype (dtype ):
1071
1071
return self .astype (dtype )
1072
1072
else :
1073
1073
return self .astype (object )
@@ -1351,7 +1351,7 @@ def eval(self, func, other, errors='raise', try_cast=False, mgr=None):
1351
1351
values , values_mask , other , other_mask = self ._try_coerce_args (
1352
1352
transf (values ), other )
1353
1353
except TypeError :
1354
- block = self .coerce_to_target_dtype (orig_other )
1354
+ block = self .coerce_to_target_dtype (orig_other , True )
1355
1355
return block .eval (func , orig_other ,
1356
1356
errors = errors ,
1357
1357
try_cast = try_cast , mgr = mgr )
0 commit comments