- Consider it is a pandas dataframe ordered by User and Timestamp
- See the 1st table - There are two groups of users - User 1 and 2
- The content Plus is part of User 1 and comes after the content END of User 1
- The content Cast is part of User 2 and comes after the content END of User 2
Q: How do I drop all rows that could exist after the content END, based on it's timestamp for each user group like demonstrating in the 2nd table.
Please, do not understand that I just want to drop the last row of each group. Imagine that I would have many others.
I would not like want to use a loop and if/else structure for this purpose. Instead, I was trying without success something like this
df[df['timestamp'] < (df.groupby('user')['timestamp'].transform('max'))]
But I need to add the content condition (END), and consider the comparisons IN THE SAME GROUP. In this case it's been considered the entire df timestamp.
Regards
