I have a DataFrame as shown in the picture:
I want to compare the current row and the next, whether df['Time'] is the same, and df['MessageType'] is 'D' followed by 'A'. If the condition is satisfied, remove the row that contains 'D' and rename the value 'A' to 'AMEND'.
Something like...
if df['Time'] (current) == df['Time'] (next) & df['MessageType'] (current) == 'D' is followed by df['MessageType'] (next) == 'A':
del current row
df['MessageType'] (next_row).rename({'A': 'AMEND'})