Python
#23

Deduplicate DataFrames by Subset Columns in Pandas

EasyFlipkart
Interview Question #23
Asked at Flipkart

Given an event log with `user_id`, `event_name`, and `timestamp`, remove duplicate user actions on the same event, keeping only the most recent occurrence (`keep='last'`).

Input Table: df
3 rows preview
user_idevent_nametimestamp
101add_to_cart2026-02-01 10:00:00
101add_to_cart2026-02-01 10:05:00
102add_to_cart2026-02-01 11:00:00
Expected Output Structure2 rows
user_idevent_nametimestamp
101add_to_cart2026-02-01 10:05:00
102add_to_cart2026-02-01 11:00:00
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

Python 3.10 (Pandas)
Environment Ready

Starting the real Python + pandas runtime (one-time download)…

Chat with us