I have 2 dataframes like following:
df1
id salary
0 1 1000
1 2 2000
df2
id txn age gender
0 1 6 23 M
1 1 4 23 M
2 2 10 31 F
3 2 5 31 F
4 2 8 31 F
I want to join the dataframes as following:
df3
id salary age gender
0 1 1000 23 M
1 2 2000 31 F
I am using the following code but getting a total of 5 rows. However, I want only 2 rows like above dataframe
d3 = pd.merge(d1, d2, on='id', how='left')
What is the correct way to join the dataframes without getting duplicates?