I have the following frame:
df1 = pd.DataFrame.from_dict({'A':[3,5,1,7], 'DateTime' : pd.date_range("11:00", "14:00", freq="60min")}).set_index('DateTime') df2 = pd.DataFrame.from_dict({'B':[13,15,1,17], 'DateTime' : pd.date_range("12:00", "15:00", freq="60min")}).set_index('DateTime')
I am trying to do the following:
pd.concat([df1, df2], join='outer') AB DateTime 2017-04-19 11:00:00 3.0 NaN 2017-04-19 12:00:00 5.0 NaN 2017-04-19 13:00:00 1.0 NaN 2017-04-19 14:00:00 7.0 NaN 2017-04-19 12:00:00 NaN 13.0 2017-04-19 13:00:00 NaN 15.0 2017-04-19 14:00:00 NaN 1.0 2017-04-19 15:00:00 NaN 17.0
How to get the following instead:
AB DateTime 2017-04-19 11:00:00 3.0 NaN 2017-04-19 12:00:00 5.0 13.0 2017-04-19 13:00:00 1.0 15.0 2017-04-19 14:00:00 7.0 1.0 2017-04-19 15:00:00 NaN 17.0
Zanam source share