i am working on a pandas dataframe which is the image of this csv file :
as you can see, lines 4,5 and 6 represents a time, I would like to merge those three lanes in order to get a dataframe like this :
So the question is : What is the most efficient way to do this ? I've been thinking about :
allRows=[]
for row in df.itertuples():
allRows.append(row)
i=0
while (i<len(allRows)):
if("time" in allRows[i][4]):
ts=str(allRows[i][5])+":"+str(allRows[i+1][5])+":"+str(allRows[i+2][5]) #concatenate time data
label=allRows[i][1].split(".")[0]+"."+allRows[i][1].split(".")[1] #creation of the new label
df.set_value(i,'Result',ts)
df.set_value(i,'src_label_designation', label)
df.drop([i+1,i+2]) #suppression of useless rows
i=i+1
i am not really familiar to pandas dataframes so i know my solution looks pretty ugly so if you can do it better i'll take it :)