I have two data frames below:
import pandas as pd data1 = {'date' : ['1', '2','3'], 'value1' : ['a', 'b' ,'c'], 'value2' : ['12','24','4']} data2 = {'date' : ['2','3','4'], 'value1' : ['b', 'c' ,'g'], 'value2' : ['24','4','55']} df1 = pd.DataFrame(data1) df1 = df1.set_index('date') df2 = pd.DataFrame(data2) df2 = df2.set_index('date') and here is my desired output:
desired_result = {'date' : ['1','2','3','4'], 'value1' : ['a', 'b', 'c', 'g'], 'value2' : ['12', '24', '4', '55']} I have tried all different kinds of merge, join, concat but couldn't figure it out.