Skip to content

TST: Test key dtype cast after merge #29030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 22, 2019
9 changes: 9 additions & 0 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,15 @@ def test_merge_on_ints_floats(self, int_vals, float_vals, exp_vals):
result = B.merge(A, left_on="Y", right_on="X")
assert_frame_equal(result, expected[["Y", "X"]])

def test_merge_key_dtype_cast(self):
# GH 17044
df1 = DataFrame({'key': [1., 2.], 'c1': [10, 20]})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to specify columns for the Py35 build, else the dict is sorted.

df2 = DataFrame({'key': [2], 'c2': [200]})
result = df1.merge(df2, on='key', how='left')
expected = DataFrame({'key': [1.0, 2.0], 'c1': [10, 20], 'c2': [np.nan, 200.0]})
# df['key'].dtype == 'float64'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this comment?

tm.assert_frame_equal(result, expected)

def test_merge_on_ints_floats_warning(self):
# GH 16572
# merge will produce a warning when merging on int and
Expand Down