I have two dataframes as show below:
df1 =
index value
2014-05-21 09:30:00 0.0
2014-05-21 10:00:00 10.0
2014-05-21 10:30:00 3.0
.....
2017-07-10 22:30:00 18.3
2017-07-10 23:00:00 7.6
2017-07-10 23:30:00 0.0
the length is equal to 55037 , and the other one
df2 =
index value
2014-05-21 09:00:00 0.0
2014-05-21 10:00:00 13.0
.....
2017-07-10 21:00:00 1.6
2017-07-10 22:00:00 32.1
2017-07-10 23:00:00 7.6
the length is equal to 27519, the two dataframe above are groupby with different time step, now I would like to match the time step in the beginning and end automatic.
For example, the "2014-05-21 09:00:00" is lack in df1, how can I write a function, put the df1 and it would check if the beginning and end matched df2, then return a new df1 which in the beginning and end equal to df2 and the value equal to zero.
so in the end the new df1 would as show below,
new_df1 =
index value
2014-05-21 09:00:00 0.0
2014-05-21 09:30:00 0.0
2014-05-21 10:00:00 10.0
2014-05-21 10:30:00 3.0
.....
2017-07-10 22:30:00 18.3
2017-07-10 23:00:00 7.6
2017-07-10 23:30:00 0.0
and length equal to 55038 (make sure it is two times large than df2)
Anyone have idea ? Thanks in adavance!