Problem 4: Keep Last Occurrence Instead of First
Easypython
Problem Description
Write a Python program that removes duplicate rows from a DataFrame, but keeps the LAST occurrence of each duplicate instead of the first.
Input
A DataFrame containing duplicate rows.
Output
The DataFrame after removing duplicates, retaining the last occurrence of each.
Constraints
- None specific.
Example Input
text{"id": [1, 2, 1], "status": ["pending", "active", "confirmed"]}
Example Output
textid status 1 2 active 2 1 confirmed
Concepts Covered
drop_duplicates(keep="last").