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 authored and jreback committed Jul 16, 2017
1 parent 0ae525b commit cecf637
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 cecf637

Please sign in to comment.