I'm trying to iterate through a data frame and pull out values that were not in the previous group
. So if I have:
group | ID |
---|---|
1 | 1 |
1 | 2 |
1 | 3 |
2 | 4 |
2 | 5 |
2 | 1 |
3 | 6 |
3 | 5 |
3 | 1 |
3 | 3 |
Then these would be the rows that appear as new values not in the previous group
This is my goal:
group | ID |
---|---|
1 | NA |
2 | 4 |
2 | 5 |
3 | 6 |
3 | 3 |
Would this use a for loop and if_elif statement to dynamically remove from the prior number group?
Thank you!