Skip to content
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

Merge even on NaN #28522

Closed
b060149ee opened this issue Sep 19, 2019 · 3 comments
Closed

Merge even on NaN #28522

b060149ee opened this issue Sep 19, 2019 · 3 comments
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@b060149ee
Copy link

b060149ee commented Sep 19, 2019

Sample code

# Your code here
import pandas as pd
import numpy as np

df = pd.DataFrame({'A': [1,2,3,4], 'B': [1,2,3,4]})
df1 = pd.DataFrame({'A': [1,2, 3, 3, 4], 'B': [1,2,3, np.NaN, np.NaN],'C': ['a','b','a','c','d']})

df2=df.merge(df1, on=['A','B'], how='left')
![df2](https://user-images.githubusercontent.com/55535963/65235326-fabb5580-daf3-11e9-9c55-9c3b98f14e36.png)


df3=pd.DataFrame({'A': [1,2, 3, 3, 4], 'B': [1,2,3, np.NaN, np.NaN],'C': ['a','b','a', 'c','d']})
![df3](https://user-images.githubusercontent.com/55535963/65235333-fe4edc80-daf3-11e9-8d6e-1fa3d5de8339.png)

Problem description

Just want an option on merge function, which would take df and df1 to get df3 as well.

@TomAugspurger
Copy link
Contributor

We've had previous discussions about this. Can you search for them?

@b060149ee
Copy link
Author

I had searched before creating the ticket but clearly didn't seem to have done it properly. Sorry about that.

Is this what you were referring to?

If so, I was just asking for an option on the merge method. If you think it is against the standards, can you please help me with a neat way of getting the above-expected output? Thanks in advance

@jbrockmendel jbrockmendel added the Reshaping Concat, Merge/Join, Stack/Unstack, Explode label Oct 16, 2019
@mroeschke
Copy link
Member

Closing as duplicate of #32306 with a more recent discussion on the future policy we want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

4 participants