Skip to content

Commit

Permalink
check if float values equal to int representation and add warning
Browse files Browse the repository at this point in the history
  • Loading branch information
reidy-p committed Nov 20, 2017
1 parent 6b2e978 commit 7e1f82a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,16 +914,29 @@ def _maybe_coerce_merge_keys(self):
continue

# check whether ints and floats
if is_integer_dtype(rk) and is_float_dtype(lk):
elif is_integer_dtype(rk) and is_float_dtype(lk):
if not (lk == lk.astype(rk.dtype)).all():
warnings.warn('You are merging on int and float '
'columns where the float values '
'are not equal to their int '
'representation', UserWarning)
continue

if is_float_dtype(rk) and is_integer_dtype(lk):
elif is_float_dtype(rk) and is_integer_dtype(lk):
if not (rk == rk.astype(lk.dtype)).all():
warnings.warn('You are merging on int and float '
'columns where the float values '
'are not equal to their int '
'representation', UserWarning)
continue

# let's infer and see if we are ok
if lib.infer_dtype(lk) == lib.infer_dtype(rk):
elif lib.infer_dtype(lk) == lib.infer_dtype(rk):
continue

else:
pass

# Houston, we have a problem!
# let's coerce to object if the dtypes aren't
# categorical, otherwise coerce to the category
Expand Down

0 comments on commit 7e1f82a

Please sign in to comment.