How can I merge two data without losing date both of them

all Could you please help me with merging data, I try to merge data1 and data2 by typing this code: “merged3= pd.merge(left = merged2 , right = user, how=’outer’,on=[‘user_id’]).fillna(0)” . But the problem is month1 in data1 disapper. How can I keep month1 column after merging data1 with data2 . You can see the result in data3 picture. Thanks in advance:enter image description here

enter image description here

enter image description here

Answer

I think you need you reset your index for merge2 df and then merge again,

merged2 = merged2.reset_index()
merged3= pd.merge(left = merged2 , right = user, how='outer',on=['user_id']).fillna(0)