I am trying to apply a groupBy statement on a set of IDs which are stamped with one or more (usually more) codes. The codes are all in the same column. Then I want to grab only those IDs that do have code1, but not code2.
The dataframe looks as follows:
| ID | Code |
| -------- | -------------- |
| 123| Code1|
| 123| Code2|
| 234| Code1|
| 567| Code1|
| 567| Code2|
I know this can be feasible by using left_anti join as well, but would like to be able to do this also in a groupby Statement
Anybody with any advice?