'Pandas Fill rows missing in date range
I have a Dataframe that represents a hotel reservations by date:
date volume city
2020-01-05 10 NY
2020-01-06 10 NY
2020-01-07 30 NY
The Dataframe is ultimately being written to the Database and because of that I need to have a complete range of dates from a given point in the past to a given point in the future, for example, the Dataframe (for entire 2020) I need should look like this:
date volume city
2020-01-01 0 NY
2020-01-02 0 NY
2020-01-03 0 NY
2020-01-04 0 NY
2020-01-05 10 NY
2020-01-06 10 NY
2020-01-07 30 NY
...
2020-12-31 0 NY
It's important that all the rows filling the range have a volume=0 and the city is repeated in the entire dataset.
How can I effective convert my Dataframe to fill dates missing in the range ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
