I have a df that looks like this:
var1 var2 var3
0 a 1
0 b 7
0 c 5
0 d 4
0 z 8
1 t 9
1 a 2
2 p 3
.. .. ..
60 c 3
I'm attempting to create lists of each set of values from var2
that correspond to a given value from var1
. So, my output would look something like this:
list_0: a, b, c, d, z
list_1: t, a
list_2: p
list_60: c
Currently I'm trying to work out a loop to do this, something like:
for i in range(df.var2.max()):
var2_i = (x for x in df.var1.to_list())
Though the lists don't seem to be iteratively created here. Perhaps there's a better way to accomplish my goal?