I have a list like the one below.
Gamecode rush pass
23....89 347
23....89 650
23....90 654
23....90 230
the code is below.
temp = {}
for row in combineddff.itertuples():
temp={}
if row[1] in ('RUSH', 'PASS'):
temp['GameCode'] = row[0]
if row[1] == 'RUSH':
temp['rush'] = row[10]
else:
temp['pass'] = row[10]
else:
continue
templist.append(temp)
print templist
my_df = pd.DataFrame(templist)
my_df.to_csv('data/results_yards.csv', index=False, header=False)
I want to combine the rush and pass values of separate rows in the templist into one row with "GameCode", "Rush" and "Pass" as values. kindly help.