Skip to content

Commit 27673ff

Browse files
author
aschade
committed
BUG: Returning other dtype when first is bool and other is int or float
1 parent e8620ab commit 27673ff

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/core/internals.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,8 +1067,10 @@ def coerce_to_target_dtype(self, other):
10671067
return self
10681068

10691069
if self.is_bool or is_object_dtype(dtype) or is_bool_dtype(dtype):
1070-
# we don't upcast to bool
1071-
return self.astype(object)
1070+
if is_float_dtype(dtype) or is_integer_dtype(dtype):
1071+
return self.astype(dtype)
1072+
else:
1073+
return self.astype(object)
10721074

10731075
elif ((self.is_float or self.is_complex) and
10741076
(is_integer_dtype(dtype) or is_float_dtype(dtype))):

0 commit comments

Comments
 (0)