Skip to content

Commit

Permalink
TST: Test key dtype cast after merge (pandas-dev#29030)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertvillanova authored and Mateusz Górski committed Nov 18, 2019
1 parent 39a57ce commit 3422286
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 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,17 @@ 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.0, 2.0], "v1": [10, 20]}, columns=["key", "v1"])
df2 = DataFrame({"key": [2], "v2": [200]}, columns=["key", "v2"])
result = df1.merge(df2, on="key", how="left")
expected = DataFrame(
{"key": [1.0, 2.0], "v1": [10, 20], "v2": [np.nan, 200.0]},
columns=["key", "v1", "v2"],
)
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

0 comments on commit 3422286

Please sign in to comment.