I have a dataframe df :-
| ID | Date | Event |
|---|---|---|
| 3 | 04-09-2013 | Success |
| 3 | 27-09-2013 | Success |
| 3 | 14-10-2013 | Success |
| 3 | 15-10-2013 | |
| 3 | 18-10-2013 | Form |
| 3 | 19-10-2013 | Click |
If the first event for every group of ID is Success or followed by Consecutive Success(note
strictly start with and /or followed by consecutive Success )then I want to drop the ID from the dataframe(Drop all the rows for that ID from the df)
Also if the case where the group is this way :-
| ID | Date | Event |
|---|---|---|
| 4 | 04-09-2013 | Success |
| 4 | 27-09-2013 | Success |
| 4 | 14-10-2013 | |
| 4 | 15-10-2013 | |
| 4 | 18-10-2013 | Success |
| 4 | 18-10-2013 | Success |
| 4 | 18-10-2013 | Click |
Expected output to be (i.e a.)remove rows if the first event/consecutive events are Success and also b.)drop the events(rows) after the last/latest success within each group(taken one example of Event click but if there are more events those are to be dropped as well):
| ID | Date | Event |
|---|---|---|
| 4 | 14-10-2013 | |
| 4 | 15-10-2013 | |
| 4 | 18-10-2013 | Success |
| 4 | 18-10-2013 | Success |
b.) is valid for every group irrespective of how the Event starts( for example ) :-
| ID | Date | Event |
|---|---|---|
| 5 | 14-10-2013 | |
| 5 | 15-10-2013 | Click |
| 5 | 18-10-2013 | Success |
| 5 | 18-10-2013 |
Expected :-
| ID | Date | Event |
|---|---|---|
| 5 | 14-10-2013 | |
| 5 | 15-10-2013 | Click |
| 5 | 18-10-2013 | Success |
How can this be achieved?