I have a collection of transactions with a date and a price column:
+---------------------------+-------+
| Date | Price |
+---------------------------+-------+
| 2016-05-27 10:02:24+00:00 | 2.90 |
| 2016-05-27 10:02:24+00:00 | 14.90 |
| 2016-05-29 07:47:09+00:00 | 12.90 |
| 2016-05-29 11:56:32+00:00 | 16.90 |
| 2016-05-29 22:10:08+00:00 | 11.92 |
+---------------------------+-------+
as it is possible to understand from the table not every day a transaction happened, and in some cases several transactions happened the same day.
My question is: how can I create a DataFrame with dates from the oldest transaction to the newest and add to this DataFrame missing dates with price 0, while keepping multiple rows for transaction that happened in the same day? A better example will be in the following table:
+---------------------------+-------+
| Date | Price |
+---------------------------+-------+
| 2016-05-27 10:02:24+00:00 | 2.90 |
| 2016-05-27 10:02:24+00:00 | 14.90 |
| 2016-05-28 00:00:00+00:00 | 0.00 |
| 2016-05-29 07:47:09+00:00 | 12.90 |
| 2016-05-29 11:56:32+00:00 | 16.90 |
| 2016-05-29 22:10:08+00:00 | 11.92 |
+---------------------------+-------+
I have tried to create a series with DateRange from the oldest to the newest, and then adding the series to the DataFrame, but doing this leads to having some missing values:
d2 = pd.Series(pd.date_range(min(df.Date), max(df.Date)))
df['dates'] = d2