Generate Friendship List with Acceptance Dates Using Pandas
RobloxData Scientist · OnsiteLast updated
This question evaluates proficiency in data manipulation and relational reasoning using Python/pandas, focusing on transforming event logs into canonical pairwise relationships and extracting activation timestamps.
friend_events
| requester_id | accepter_id | request_date | accept_date |
|---|---|---|---|
| 1 | 2 | 2024-01-01 | 2024-01-02 |
| 2 | 3 | 2024-01-03 | 2024-01-05 |
| 3 | 2 | 2024-01-04 | 2024-01-05 |
| 2 | 1 | 2024-01-06 | 2024-01-07 |
| 4 | 1 | 2024-01-08 | 2024-01-09 |
Scenario
After launching a social feature, product wants a list of confirmed friendships with the date they formed.
Question
Given friend request logs, write Python/pandas that returns each distinct user pair once (smaller id first) and the acceptance date when the friendship became active.
Hints
Filter accepted rows, sort ids, drop_duplicates.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.