What I am trying to do is insert records into a dataset whenever a line is missing.
If you look at the data set above, it contains 3 columns of attributes and then 2 numeric values. The third column TTF, is incremental and should not skip any values. In this example it is missing 2 rows which are shown at the bottom. So what I want my code to do would be insert those 2 rows into the result set (i.e. Computer - Display is missing TTF of 5, and Television - Power Supply is missing TTF of 6. I would set the repair value to 0, and the running total value to the same as the previous row).
I was thinking I would approach it by splitting the column names and recursively walking through the first 2, and then 1 to 8 for the third.
for i in range(len(Product)):
for j in range(len(Module)):
for k in range(1, 8):
# Check if the Repair value is there if not make it 0
# If Repair value is missing, look up previous Running Total
Does this seem like the best approach? Any help with the actual code to accomplish this would really be appreciated.
EDIT: Here is code reading in the DF, since that seems to be confusing based on the excel screenshot.
>>> import pandas as pd
>>>
>>> df = pd.read_csv('minimal.csv')
>>>
>>> df
Product Module TTF Repair Running Total
0 Computer Display 1 3 3
1 Computer Display 2 2 5
2 Computer Display 3 1 6
3 Computer Display 4 5 11
4 Computer Display 6 4 15
5 Computer Display 7 3 18
6 Computer Display 8 2 20
7 Television Power Supply 1 7 7
8 Television Power Supply 2 6 13
9 Television Power Supply 3 4 17
10 Television Power Supply 4 5 22
11 Television Power Supply 5 6 28
12 Television Power Supply 7 7 35
13 Television Power Supply 8 8 43