Concatenating selected columns from two data frames in python pandas
I am trying to concatenate some of the columns in my data frame in python pandas. Say, I have the following data frames:
df1['Head','Body','feat1','feat2']
df2['Head','Body','feat3','feat4']
I want to merge the dataframes into:
merged_df['Head','Body','feat1','feat2','feat3',feat4']
Intuitively, I did this:
merged_df = pd.concat([df1, df2['feat3','feat4'],axis=1)
It did not work. I did my research and did this:
merged_df =
df1[['Head','Body','feat1','feat2']].merge(df2[['Head','feat3','feat4']],
on='Head', how='left')
It worked but caused some discrepancies on my data. Turns out some of my 'Head' data are not unique. So now I am just looking for the most straight forward way to concatenate the selected columns from DF2 into my DF1. Note that both data frames follow the same order, so the row 1 in DF1 is directly related to row 1 in DF2, so is the row 8120th and so on..
Thanks
python pandas dataframe
add a comment |
I am trying to concatenate some of the columns in my data frame in python pandas. Say, I have the following data frames:
df1['Head','Body','feat1','feat2']
df2['Head','Body','feat3','feat4']
I want to merge the dataframes into:
merged_df['Head','Body','feat1','feat2','feat3',feat4']
Intuitively, I did this:
merged_df = pd.concat([df1, df2['feat3','feat4'],axis=1)
It did not work. I did my research and did this:
merged_df =
df1[['Head','Body','feat1','feat2']].merge(df2[['Head','feat3','feat4']],
on='Head', how='left')
It worked but caused some discrepancies on my data. Turns out some of my 'Head' data are not unique. So now I am just looking for the most straight forward way to concatenate the selected columns from DF2 into my DF1. Note that both data frames follow the same order, so the row 1 in DF1 is directly related to row 1 in DF2, so is the row 8120th and so on..
Thanks
python pandas dataframe
Can you create a small dataset and expected output?
– Scott Boston
Jan 2 at 2:43
df1.merge(df2,on=['Head','Body'],how='left')
– Wen-Ben
Jan 2 at 2:43
add a comment |
I am trying to concatenate some of the columns in my data frame in python pandas. Say, I have the following data frames:
df1['Head','Body','feat1','feat2']
df2['Head','Body','feat3','feat4']
I want to merge the dataframes into:
merged_df['Head','Body','feat1','feat2','feat3',feat4']
Intuitively, I did this:
merged_df = pd.concat([df1, df2['feat3','feat4'],axis=1)
It did not work. I did my research and did this:
merged_df =
df1[['Head','Body','feat1','feat2']].merge(df2[['Head','feat3','feat4']],
on='Head', how='left')
It worked but caused some discrepancies on my data. Turns out some of my 'Head' data are not unique. So now I am just looking for the most straight forward way to concatenate the selected columns from DF2 into my DF1. Note that both data frames follow the same order, so the row 1 in DF1 is directly related to row 1 in DF2, so is the row 8120th and so on..
Thanks
python pandas dataframe
I am trying to concatenate some of the columns in my data frame in python pandas. Say, I have the following data frames:
df1['Head','Body','feat1','feat2']
df2['Head','Body','feat3','feat4']
I want to merge the dataframes into:
merged_df['Head','Body','feat1','feat2','feat3',feat4']
Intuitively, I did this:
merged_df = pd.concat([df1, df2['feat3','feat4'],axis=1)
It did not work. I did my research and did this:
merged_df =
df1[['Head','Body','feat1','feat2']].merge(df2[['Head','feat3','feat4']],
on='Head', how='left')
It worked but caused some discrepancies on my data. Turns out some of my 'Head' data are not unique. So now I am just looking for the most straight forward way to concatenate the selected columns from DF2 into my DF1. Note that both data frames follow the same order, so the row 1 in DF1 is directly related to row 1 in DF2, so is the row 8120th and so on..
Thanks
python pandas dataframe
python pandas dataframe
asked Jan 2 at 2:40
chmscrbbrfckchmscrbbrfck
178
178
Can you create a small dataset and expected output?
– Scott Boston
Jan 2 at 2:43
df1.merge(df2,on=['Head','Body'],how='left')
– Wen-Ben
Jan 2 at 2:43
add a comment |
Can you create a small dataset and expected output?
– Scott Boston
Jan 2 at 2:43
df1.merge(df2,on=['Head','Body'],how='left')
– Wen-Ben
Jan 2 at 2:43
Can you create a small dataset and expected output?
– Scott Boston
Jan 2 at 2:43
Can you create a small dataset and expected output?
– Scott Boston
Jan 2 at 2:43
df1.merge(df2,on=['Head','Body'],how='left')
– Wen-Ben
Jan 2 at 2:43
df1.merge(df2,on=['Head','Body'],how='left')
– Wen-Ben
Jan 2 at 2:43
add a comment |
2 Answers
2
active
oldest
votes
taking an example, lets suppose we have two DataFrame's as df1
and df2
, so, if the values are of the columns are same or unique across then you simple do merge which will align the columns as you desired.
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
Step 1 solution:
>>> pd.merge(df1, df2, on=['Head', 'Body'])
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 1 1
1 2 2 2 2 2 2
2 3 3 3 3 3 3
Secondly, if you have the columns values are different as follows then you can use pd.concat or pd.merge:
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 4 1 1 1
1 5 2 2 2
2 6 3 3 3
Step 2 solution:
If you want to use union of keys from both frames, then you can do it both with concat
and merge
as follows:
>>> pd.concat([df1,df2], join="outer", sort=False)
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
0 4 1 NaN NaN 1.0 1.0
1 5 2 NaN NaN 2.0 2.0
2 6 3 NaN NaN 3.0 3.0
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='outer')
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
3 4 1 NaN NaN 1.0 1.0
4 5 2 NaN NaN 2.0 2.0
5 6 3 NaN NaN 3.0 3.0
Or you can opt to have :
a) if you want to use keys from left frame
pd.merge(df1, df2, on=['Head', 'Body'], how='left')
b) if you want to use keys from right frame
pd.merge(df1, df2, on=['Head', 'Body'], how='right')
Default it takes 'inner'.
inner: use intersection of keys from both frames, similar to a SQL
inner join; preserve the order of the left keys
You Can see DataFrame.merge for detail options..
After looking at your workaround, you want to use the keys from left frame
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='left')
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 NaN NaN
1 2 2 2 2 NaN NaN
2 3 3 3 3 NaN NaN
Thank you.. this post have been very helpful.
– chmscrbbrfck
Jan 2 at 15:33
You Welcome, by the way what made you to switch the answer? what is your desired output , this was what explained in your post
– pygo
Jan 2 at 15:39
Both are correct though.. Yours was well explained. I think the basic pandas data frame tutorials out there misses this type of merging. Kudos!
– chmscrbbrfck
Jan 2 at 16:38
add a comment |
I think you need value assign , and it will ignore index
df1['feat3']=df2['feat3'].values
df1['feat4']=df2['feat4'].values
This worked thanks
– chmscrbbrfck
Jan 2 at 15:33
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000636%2fconcatenating-selected-columns-from-two-data-frames-in-python-pandas%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
taking an example, lets suppose we have two DataFrame's as df1
and df2
, so, if the values are of the columns are same or unique across then you simple do merge which will align the columns as you desired.
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
Step 1 solution:
>>> pd.merge(df1, df2, on=['Head', 'Body'])
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 1 1
1 2 2 2 2 2 2
2 3 3 3 3 3 3
Secondly, if you have the columns values are different as follows then you can use pd.concat or pd.merge:
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 4 1 1 1
1 5 2 2 2
2 6 3 3 3
Step 2 solution:
If you want to use union of keys from both frames, then you can do it both with concat
and merge
as follows:
>>> pd.concat([df1,df2], join="outer", sort=False)
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
0 4 1 NaN NaN 1.0 1.0
1 5 2 NaN NaN 2.0 2.0
2 6 3 NaN NaN 3.0 3.0
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='outer')
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
3 4 1 NaN NaN 1.0 1.0
4 5 2 NaN NaN 2.0 2.0
5 6 3 NaN NaN 3.0 3.0
Or you can opt to have :
a) if you want to use keys from left frame
pd.merge(df1, df2, on=['Head', 'Body'], how='left')
b) if you want to use keys from right frame
pd.merge(df1, df2, on=['Head', 'Body'], how='right')
Default it takes 'inner'.
inner: use intersection of keys from both frames, similar to a SQL
inner join; preserve the order of the left keys
You Can see DataFrame.merge for detail options..
After looking at your workaround, you want to use the keys from left frame
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='left')
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 NaN NaN
1 2 2 2 2 NaN NaN
2 3 3 3 3 NaN NaN
Thank you.. this post have been very helpful.
– chmscrbbrfck
Jan 2 at 15:33
You Welcome, by the way what made you to switch the answer? what is your desired output , this was what explained in your post
– pygo
Jan 2 at 15:39
Both are correct though.. Yours was well explained. I think the basic pandas data frame tutorials out there misses this type of merging. Kudos!
– chmscrbbrfck
Jan 2 at 16:38
add a comment |
taking an example, lets suppose we have two DataFrame's as df1
and df2
, so, if the values are of the columns are same or unique across then you simple do merge which will align the columns as you desired.
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
Step 1 solution:
>>> pd.merge(df1, df2, on=['Head', 'Body'])
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 1 1
1 2 2 2 2 2 2
2 3 3 3 3 3 3
Secondly, if you have the columns values are different as follows then you can use pd.concat or pd.merge:
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 4 1 1 1
1 5 2 2 2
2 6 3 3 3
Step 2 solution:
If you want to use union of keys from both frames, then you can do it both with concat
and merge
as follows:
>>> pd.concat([df1,df2], join="outer", sort=False)
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
0 4 1 NaN NaN 1.0 1.0
1 5 2 NaN NaN 2.0 2.0
2 6 3 NaN NaN 3.0 3.0
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='outer')
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
3 4 1 NaN NaN 1.0 1.0
4 5 2 NaN NaN 2.0 2.0
5 6 3 NaN NaN 3.0 3.0
Or you can opt to have :
a) if you want to use keys from left frame
pd.merge(df1, df2, on=['Head', 'Body'], how='left')
b) if you want to use keys from right frame
pd.merge(df1, df2, on=['Head', 'Body'], how='right')
Default it takes 'inner'.
inner: use intersection of keys from both frames, similar to a SQL
inner join; preserve the order of the left keys
You Can see DataFrame.merge for detail options..
After looking at your workaround, you want to use the keys from left frame
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='left')
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 NaN NaN
1 2 2 2 2 NaN NaN
2 3 3 3 3 NaN NaN
Thank you.. this post have been very helpful.
– chmscrbbrfck
Jan 2 at 15:33
You Welcome, by the way what made you to switch the answer? what is your desired output , this was what explained in your post
– pygo
Jan 2 at 15:39
Both are correct though.. Yours was well explained. I think the basic pandas data frame tutorials out there misses this type of merging. Kudos!
– chmscrbbrfck
Jan 2 at 16:38
add a comment |
taking an example, lets suppose we have two DataFrame's as df1
and df2
, so, if the values are of the columns are same or unique across then you simple do merge which will align the columns as you desired.
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
Step 1 solution:
>>> pd.merge(df1, df2, on=['Head', 'Body'])
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 1 1
1 2 2 2 2 2 2
2 3 3 3 3 3 3
Secondly, if you have the columns values are different as follows then you can use pd.concat or pd.merge:
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 4 1 1 1
1 5 2 2 2
2 6 3 3 3
Step 2 solution:
If you want to use union of keys from both frames, then you can do it both with concat
and merge
as follows:
>>> pd.concat([df1,df2], join="outer", sort=False)
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
0 4 1 NaN NaN 1.0 1.0
1 5 2 NaN NaN 2.0 2.0
2 6 3 NaN NaN 3.0 3.0
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='outer')
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
3 4 1 NaN NaN 1.0 1.0
4 5 2 NaN NaN 2.0 2.0
5 6 3 NaN NaN 3.0 3.0
Or you can opt to have :
a) if you want to use keys from left frame
pd.merge(df1, df2, on=['Head', 'Body'], how='left')
b) if you want to use keys from right frame
pd.merge(df1, df2, on=['Head', 'Body'], how='right')
Default it takes 'inner'.
inner: use intersection of keys from both frames, similar to a SQL
inner join; preserve the order of the left keys
You Can see DataFrame.merge for detail options..
After looking at your workaround, you want to use the keys from left frame
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='left')
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 NaN NaN
1 2 2 2 2 NaN NaN
2 3 3 3 3 NaN NaN
taking an example, lets suppose we have two DataFrame's as df1
and df2
, so, if the values are of the columns are same or unique across then you simple do merge which will align the columns as you desired.
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
Step 1 solution:
>>> pd.merge(df1, df2, on=['Head', 'Body'])
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 1 1
1 2 2 2 2 2 2
2 3 3 3 3 3 3
Secondly, if you have the columns values are different as follows then you can use pd.concat or pd.merge:
$ df1
Head Body feat1 feat2
0 1 1 1 1
1 2 2 2 2
2 3 3 3 3
$ df2
Head Body feat3 feat4
0 4 1 1 1
1 5 2 2 2
2 6 3 3 3
Step 2 solution:
If you want to use union of keys from both frames, then you can do it both with concat
and merge
as follows:
>>> pd.concat([df1,df2], join="outer", sort=False)
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
0 4 1 NaN NaN 1.0 1.0
1 5 2 NaN NaN 2.0 2.0
2 6 3 NaN NaN 3.0 3.0
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='outer')
Head Body feat1 feat2 feat3 feat4
0 1 1 1.0 1.0 NaN NaN
1 2 2 2.0 2.0 NaN NaN
2 3 3 3.0 3.0 NaN NaN
3 4 1 NaN NaN 1.0 1.0
4 5 2 NaN NaN 2.0 2.0
5 6 3 NaN NaN 3.0 3.0
Or you can opt to have :
a) if you want to use keys from left frame
pd.merge(df1, df2, on=['Head', 'Body'], how='left')
b) if you want to use keys from right frame
pd.merge(df1, df2, on=['Head', 'Body'], how='right')
Default it takes 'inner'.
inner: use intersection of keys from both frames, similar to a SQL
inner join; preserve the order of the left keys
You Can see DataFrame.merge for detail options..
After looking at your workaround, you want to use the keys from left frame
>>> pd.merge(df1, df2, on=['Head', 'Body'], how='left')
Head Body feat1 feat2 feat3 feat4
0 1 1 1 1 NaN NaN
1 2 2 2 2 NaN NaN
2 3 3 3 3 NaN NaN
edited Jan 2 at 6:59
answered Jan 2 at 6:49
pygopygo
3,1951619
3,1951619
Thank you.. this post have been very helpful.
– chmscrbbrfck
Jan 2 at 15:33
You Welcome, by the way what made you to switch the answer? what is your desired output , this was what explained in your post
– pygo
Jan 2 at 15:39
Both are correct though.. Yours was well explained. I think the basic pandas data frame tutorials out there misses this type of merging. Kudos!
– chmscrbbrfck
Jan 2 at 16:38
add a comment |
Thank you.. this post have been very helpful.
– chmscrbbrfck
Jan 2 at 15:33
You Welcome, by the way what made you to switch the answer? what is your desired output , this was what explained in your post
– pygo
Jan 2 at 15:39
Both are correct though.. Yours was well explained. I think the basic pandas data frame tutorials out there misses this type of merging. Kudos!
– chmscrbbrfck
Jan 2 at 16:38
Thank you.. this post have been very helpful.
– chmscrbbrfck
Jan 2 at 15:33
Thank you.. this post have been very helpful.
– chmscrbbrfck
Jan 2 at 15:33
You Welcome, by the way what made you to switch the answer? what is your desired output , this was what explained in your post
– pygo
Jan 2 at 15:39
You Welcome, by the way what made you to switch the answer? what is your desired output , this was what explained in your post
– pygo
Jan 2 at 15:39
Both are correct though.. Yours was well explained. I think the basic pandas data frame tutorials out there misses this type of merging. Kudos!
– chmscrbbrfck
Jan 2 at 16:38
Both are correct though.. Yours was well explained. I think the basic pandas data frame tutorials out there misses this type of merging. Kudos!
– chmscrbbrfck
Jan 2 at 16:38
add a comment |
I think you need value assign , and it will ignore index
df1['feat3']=df2['feat3'].values
df1['feat4']=df2['feat4'].values
This worked thanks
– chmscrbbrfck
Jan 2 at 15:33
add a comment |
I think you need value assign , and it will ignore index
df1['feat3']=df2['feat3'].values
df1['feat4']=df2['feat4'].values
This worked thanks
– chmscrbbrfck
Jan 2 at 15:33
add a comment |
I think you need value assign , and it will ignore index
df1['feat3']=df2['feat3'].values
df1['feat4']=df2['feat4'].values
I think you need value assign , and it will ignore index
df1['feat3']=df2['feat3'].values
df1['feat4']=df2['feat4'].values
answered Jan 2 at 2:44
Wen-BenWen-Ben
114k83368
114k83368
This worked thanks
– chmscrbbrfck
Jan 2 at 15:33
add a comment |
This worked thanks
– chmscrbbrfck
Jan 2 at 15:33
This worked thanks
– chmscrbbrfck
Jan 2 at 15:33
This worked thanks
– chmscrbbrfck
Jan 2 at 15:33
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000636%2fconcatenating-selected-columns-from-two-data-frames-in-python-pandas%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you create a small dataset and expected output?
– Scott Boston
Jan 2 at 2:43
df1.merge(df2,on=['Head','Body'],how='left')
– Wen-Ben
Jan 2 at 2:43