Skip to content

Commit

Permalink
GH16875
Browse files Browse the repository at this point in the history
rearrange if clause in pandas.core.dtypes.cast.maybe_downcast_to_dtype
  • Loading branch information
jeetjitsu committed Jul 15, 2017
1 parent 468b79b commit 9f458eb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ def trans(x): # noqa
np.prod(result.shape)):
return result

# don't convert bool to float GH16875
if (issubclass(dtype.type, np.floating) and
not is_bool_dtype(result.dtype)):
return result.astype(dtype)
elif is_bool_dtype(dtype) or is_integer_dtype(dtype):
if is_bool_dtype(dtype) or is_integer_dtype(dtype):

# if we don't have any elements, just astype it
if not np.prod(result.shape):
Expand Down Expand Up @@ -146,6 +142,9 @@ def trans(x): # noqa
# hit here
if (new_result == result).all():
return new_result
elif (issubclass(dtype.type, np.floating) and
not is_bool_dtype(result.dtype)):
return result.astype(dtype)

# a datetimelike
# GH12821, iNaT is casted to float
Expand Down

0 comments on commit 9f458eb

Please sign in to comment.