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
Merged

Conversation

albertvillanova
Copy link
Contributor

@albertvillanova albertvillanova commented Oct 16, 2019

@pep8speaks
Copy link

pep8speaks commented Oct 16, 2019

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

@jbrockmendel
Copy link
Member

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'
Copy link
Member

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'
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?

@mroeschke
Copy link
Member

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]})
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.

@mroeschke
Copy link
Member

Just need to run black otherwise LGTM.

@WillAyd WillAyd added the Testing pandas testing functions or related to the test suite label Oct 22, 2019
@WillAyd WillAyd added this to the 1.0 milestone Oct 22, 2019
@WillAyd WillAyd merged commit 5546233 into pandas-dev:master Oct 22, 2019
@WillAyd
Copy link
Member

WillAyd commented Oct 22, 2019

Thanks @albertvillanova

HawkinsBA pushed a commit to HawkinsBA/pandas that referenced this pull request Oct 29, 2019
Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type casting after merge
6 participants