I have the following dataset:
input_df = pd.DataFrame({'Product':['Computer']*5 + ['Television']*7,
'Module':['Display']*5 + ['Power Supply']*7,
'TTF':[1,2,3,4,6,1,2,3,4,5,7,8]})
I would like to insert missing rows (index 4 and 11) in order to get the following dataset:
output_df = pd.DataFrame({'Product':['Computer']*6 + ['Television']*8,
'Module':['Display']*6 + ['Power Supply']*8,
'TTF':[1,2,3,4,5,6,1,2,3,4,5,6,7,8]})
What is the most efficient way to insert those rows (my real dataset is actually pretty big with a lot of different categories).
I have found a related post: How would I insert missing rows into this data set? However in this post, the index range doesn't vary from one product to another (always [1 to 8] unlike in my case where it is [1 to 6] for Computer and then [1 to 8] for Television.