I need help for this case to fill, with a new row, missing values:
This is just an example, but I have a lot of rows with different IDs
.
Input dataframe:
ID | FLAG | DATE |
---|---|---|
123 | 1 | 01/01/2021 |
123 | 0 | 01/02/2021 |
123 | 1 | 01/03/2021 |
123 | 0 | 01/06/2021 |
123 | 0 | 01/08/2021 |
777 | 0 | 01/01/2021 |
777 | 1 | 01/03/2021 |
So I have a finite set of dates
and I wanna take until the last one for each ID
(in the example, for ID = 123
: 01/01/2021, 01/02/2021, 01/03/2021... until 01/08/2021). So basically I could do a cross join with a calendar, but I don't know how can I fill missing value with a rule or a filter, after the cross join.
Expected output: (in bold the generated missing values)
ID | FLAG | DATE |
---|---|---|
123 | 1 | 01/01/2021 |
123 | 0 | 01/02/2021 |
123 | 1 | 01/03/2021 |
123 | 1 | 01/04/2021 |
123 | 1 | 01/05/2021 |
123 | 0 | 01/06/2021 |
123 | 0 | 01/07/2021 |
123 | 0 | 01/08/2021 |
777 | 0 | 01/01/2021 |
777 | 0 | 01/02/2021 |
777 | 1 | 01/03/2021 |