I have a dataframe that contains a sequence containing coded values and the day (e.g. (A,1)) on which it was recorded. My goal is to check for coded values X and Y. And if they occur on the same day, remove the Y value from the sequence.
ID Sequence
1 [(A,1), (B,1), (X,2), (Y,2), (Y,3)]
2 [(C,1), (X,2), (Y,2), (Z,2)]
3 [(C,1), (D,2), (X,3), (Y,3),(Z,3)]
The results I'm expecting are:
ID Sequence
1 [(A,1), (B,1), (X,2), (Y,3)]
2 [(C,1), (X,2), (Z,2)]
3 [(C,1), (D,2), (X,3), (Z,3)]
Is there any way I can write a function to get these results? Any help would be appreciated.