I have a data frame like so:
moves | game_id |
---|---|
e2e4 | 1 |
cfc8 | 1 |
g6e4 | 1 |
f6g8 | 2 |
f8g5 | 2 |
e2e4 | 3 |
d8b6 | 3 |
h7a3 | 3 |
I want to create a column which appends each previous string in 'moves' to a list that grows, but restarts for the next 'game_id'.
So that I create a table like so:
moves | game_id | move_list |
---|---|---|
e2e4 | 1 | e2e4 |
cfc8 | 1 | e2e4 cfc8 |
g6e4 | 1 | e2e4 cfc8 g6e4 |
f6g8 | 2 | f6g8 |
f8g5 | 2 | f6g8 f8g5 |
e2e4 | 3 | e2e4 |
d8b6 | 3 | e2e4 d8b6 |
h7a3 | 3 | e2e4 d8b6 h7a3 |
Thanks in advance for the help!