I have two dataframes:
dataframe 1:
>>>date ex_1
0 2019-12-06 0.312
1 2019-12-11 0.521
2 2019-12-31 0.305
...
and dataframe 2:
>>>date ex_2
0 2019-12-06 0.228
1 2019-12-11 0.433
2 2019-12-16 0.143
I would like to concat the two tables based on the date, so if there is overlap date, the row will contain the values for each experiment on the same row, and if there is only one day it will add it and give null to the column that has no value.
I have tried to do this based on this answer :
pd.concat([df1.set_index('date'), ndf2.set_index('date')]).sort_index(ascending=True)
and it indeed concat but the problem is that if the date appeas in two tables it duplicates:
date ex1 ex2
2019-12-06 0.312 Nan
2019-12-06 Nan 0.228
2019-12-11 0.521 Nan
2019-12-11 NaN 0.433
2019-12-16 NaN 0.143
2019-12-31 0.305 NaN
My desired output should look like this:
date ex1 ex2
2019-12-06 0.312 0.228
2019-12-11 0.521 0.433
2019-12-16 NaN 0.143
2019-12-31 0.305 NaN