-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
Hello @albertvillanova! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-10-21 19:37:44 UTC |
Travis fail is likely unrelated, but there are some linting issues you need to address |
df1 = pd.DataFrame({'key': [1., 2.], 'c1': [10, 20]}) | ||
df2 = pd.DataFrame({'key': [2], 'c2': [200]}) | ||
df = df1.merge(df2, on='key', how='left') | ||
assert df['key'].dtype == 'float64' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you could tm.assert_frame_equal
the resulting merged dataframe, that would be ideal (which checks the dtypes too.
result = df1.merge(df2, on='key', how='left')
expected = ....
tm.assert_frame_equal(result, expected)
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' |
There was a problem hiding this comment.
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?
Could you merge master? Master was broken recently, but it should be stable now. |
@@ -1437,6 +1437,14 @@ 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]}) |
There was a problem hiding this comment.
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.
Just need to run |
Thanks @albertvillanova |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff