Merging Two Dataframes In Python Pandas
I have a dataframe A: a 1 a 2 b 1 b 2 Another dataframe B: a 3 a 4 b 3 I want my result dataframe to be like a 1 3 a 1 4 a 2 3 a 2 4 b 1 3 b 2 3 I wondering how I can get
Solution 1:
A simple merge using df.merge
does this:
df1.merge(df2, on=['A'])
A B_x B_y
0 a 1 3
1 a 1 4
2 a 2 3
3 a 2 4
4 b 1 3
5 b 2 3
Post a Comment for "Merging Two Dataframes In Python Pandas"