I have a dataframe:
day Datavalue
2020-06-01 3.179695
2020-06-02 0.132487
2020-06-08 3.179695
2020-06-09 3.179695
2020-06-10 3.179695
I would like to set a date range and add any dates that aren't in the dataframe as 0 for example:
day Datavalue
2020-06-01 3.179695
2020-06-02 0.132487
2020-06-03 0
2020-06-04 0
2020-06-05 0
2020-06-06 0
2020-06-07 0
2020-06-08 3.179695
2020-06-09 3.179695
2020-06-10 3.179695
I have tried
mydates = pd.period_range(date - timedelta(40), date + timedelta(40)
x = data.set_index('day')
x = data.reindex(mydates, fill_value=0)
but this just sets it all to zeros
what am I doing wrong?
thanks
