I have a df like this:
time units cost
0 4 10
1 2 10
3 4 20
4 1 20
5 3 10
6 1 20
9 2 10
As you can see, df.time is not consecutive. If there is a missing value, I want to add a new row, populating df.time with the consecutive time value, df.units with 2 and df.cost with 20.
Expected output:
time units cost
0 4 10
1 2 10
2 2 20
3 4 20
4 1 20
5 3 10
6 1 20
7 2 20
8 2 20
9 2 10
How do I do this? I understand how to this by deconstructing all series into lists, looping through them and appending values when time is not equal to time - 1, but this seems inefficient.