I have a data frame that looks like the following with four locations:
df
Date Location Count
0 2018-11-20 loc 1 22
1 2018-11-20 loc 2 1
2 2018-11-20 loc 3 5
3 2018-11-20 loc 4 34
4 2018-11-21 loc 1 20
5 2018-11-21 loc 2 2
6 2018-11-22 loc 1 20
7 2018-11-23 loc 3 3
8 2018-11-23 loc 4 21
I am looking to fill in the missing locations with a count of 0 so that is looks like:
df
Date Location Count
0 2018-11-20 loc 1 22
1 2018-11-20 loc 2 1
2 2018-11-20 loc 3 5
3 2018-11-20 loc 4 34
4 2018-11-21 loc 1 20
5 2018-11-21 loc 2 2
6 2018-11-21 loc 3 0
7 2018-11-21 loc 4 0
8 2018-11-22 loc 1 20
9 2018-11-22 loc 2 0
10 2018-11-22 loc 3 0
11 2018-11-22 loc 4 0
12 2018-11-23 loc 1 0
13 2018-11-23 loc 2 0
14 2018-11-23 loc 3 3
15 2018-11-23 loc 4 21
The date is stored a string. What is the best way to do this? Should I convert the date first and then apply a function?