I have two dataframes (df1 and df2) in pandas with both having different columns except for the first column. Following are the dataframes for example:
df1
----------------
c1 c2 c3
----------------
1 x 10
2 y 16
3 z 20
df2
----------------
c1 c4 c5
----------------
1 xx 30
2 ym 46
2 zq 50
3 xa 60
3 ys 16
4 zm 20
I want to merge the two df such that the resulting df looks like the following:
----------------------------
c1 c2 c3 c4 c5
----------------------------
1 x 10 xx 30
2 y 16 ym 46
2 y 16 zq 50
3 z 20 xa 60
3 z 20 ys 16
4 zm 20
I have used the
pd.merge(df1, df2, how='left')
pd.merge(df1, df2, how='right')
pd.merge(df1, df2, how='inner')
pd.merge(df1, df2, how='outer')
but couldn't get the above-desired data frame. Can anybody help me with this problem? Thanks!