Please note that the real case the volume and the combination between state and country are much bigger, and not only to the value 'usa'
With the following dataframe:
import pandas as pd
data = pd.DataFrame({'state':['ny','sf','tx','ny','ny'],'country':['usa','usa','usa','usa','usa'],
'Date':['01/01/2020','01/01/2020','01/01/2020','01/02/2020','01/02/2020']})
I group the data to get the number of entries by city, country in a given date:
group_data = data.groupby(['state','country','Date']).size().to_frame().reset_index()
So I get:
| | state | country | Date | 0 |
|---:|:-------|:----------|:-----------|----:|
| 0 | ny | usa | 01/01/2020 | 1 |
| 1 | ny | usa | 01/02/2020 | 2 |
| 2 | sf | usa | 01/01/2020 | 1 |
| 3 | tx | usa | 01/01/2020 | 1 |
Ideally I would want for every entry in the dataframe, fill the date missing for the entire range max(data['Date']) and min(data['Date']) have the values filled for the subgroup state and country that's not present, so for example it should look like:
| | state | country | Date | 0 |
|---:|:-------|:----------|:-----------|----:|
| 0 | ny | usa | 01/01/2020 | 1 |
| 1 | ny | usa | 01/02/2020 | 2 |
| 2 | sf | usa | 01/01/2020 | 1 |
| 2 | sf | usa | 01/02/2020 | 0 |
| 3 | tx | usa | 01/01/2020 | 1 |
| 3 | tx | usa | 01/02/2020 | 0 |
Two entries for sf-usa and tx-usa have been added for the 2nd of Januarya 2020 with 0.