Hi,
I need to merge this two dataframes:
df1
df2
Right now I'm trying this code:
And getting this result:
Which is the simply union of both df's. I need something that produces this result:
Any ideas? Thank!!
I need to merge this two dataframes:
df1
1 2 3 4 |
pais año cantidad 0 Chile 2000 10 1 Chile 2001 11 2 Chile 2002 12 |
1 2 3 4 5 6 |
pais año cantidad 0 Chile 1999 0 1 Chile 2000 0 2 Chile 2001 0 3 Chile 2002 0 4 Chile 2003 0 |
1 |
df = pd.merge(df1,df2,on = [ 'pais' , 'año' , 'cantidad' ],how = 'outer' ) |
1 2 3 4 5 6 7 8 9 |
pais año cantidad 0 Chile 2000 10 1 Chile 2001 11 2 Chile 2002 12 3 Chile 1999 0 4 Chile 2000 0 5 Chile 2001 0 6 Chile 2002 0 7 Chile 2003 0 |
1 2 3 4 5 6 7 |
pais año cantidad 0 Chile 1999 0 1 Chile 2000 10 2 Chile 2001 11 3 Chile 2002 12 4 Chile 2002 0 5 Chile 2003 0 |