I am iterating through the dataframe and try to store the "total" list for each id.
The dataframe look like this:
id total difference
1 29 3
1 21 2
2 39 0
2 22 9
What I have tried so far:
total_list=[]
for i, row in df.iterrows():
total_list.extend(df.total.loc[df.id==row.id].tolist())
print(total_list) # this never gets print
total_list should look like [[29, 21], [39,22]]