I have the following dataframe-
my_df
-
user_id | spend | transaction_id |
--------+--------+-----------------|
1 | 45 | 12 |
2 | 33 | 45 |
3 | 12 | 33 |
1 | 22 | 56 |
1 | 77 | 99 |
2 | 44 | 68 |
My goal is to get all rows with the greatest transaction_id
for each user_id
.
So, I want my final result to look like this -
user_id | spend | transaction_id |
--------+--------+-----------------|
1 | 77 | 99 |
2 | 44 | 68 |
3 | 12 | 33 |
How do I do this?