I am trying to remove rows based on if the previous row was “added” and the current row is “removed”. My goal is to identify the rows that are only “added”.
import pandas as pd
df = pd.DataFrame({'Event_Time': ['2024-05-28 12:37:00', '2024-05-28 12:41:00', '2024-05-28 16:12:00','2024-05-08 09:40:00'],
'Name': ['Kenzie Doe', 'Kenzie Doe', 'Kenzie Doe', 'Abby Stone'],
'Action': ['Added', 'Removed', 'Added', 'Added']})
I converted the datetime so it can sort properly. The names are also sorted so all the actions for one employee are together and by proper date time.
I am not sure if muli-row and column actions can be taken in python. I would like my final result to look like this:
Event_time | Name | Action |
---|---|---|
2024-05-28 16:12:00 | Kenzie Doe | Added |
2024-05-08 09:40:00 | Abby Stone | Added |