Lets say I have two differents pandas Dataframe with different index for example:
df1:
email | other_field
_________________________________________
[email protected] | 2
[email protected] | 1
[email protected] | 6
and df2:
new_field
__________
1
7
4
The 2 dataframes have the same size. How can I merge the two of them to have this similar output?
df3:
email | other_field | new_field
________________________________________________________________
[email protected] | 2 | 1
[email protected] | 1 | 7
[email protected] | 6 | 4
I tried this:
df3 = pd.merge(df1, df2, left_index=True, right_index=True)
but despite df1 and df2 has the same size, df3 has a lower size
pd.concat([df1,df2], axis=1, ignore_index=True)