Frequent Host-Guest Pairs
Problem
You are given a DataFrame `recording_session` with columns `host_id`, `guest_id`, and `session_no`. Each row records one recording session between a host and a guest.
Return every `(host_id, guest_id)` pair that appears in **three or more** sessions. Output the two columns `host_id` and `guest_id`.
Input data
Example rows — the live problem includes the full dataset.
recording_session
| host_id | guest_id | session_no |
|---|---|---|
| 1 | 1 | 0 |
| 1 | 1 | 1 |
| 1 | 1 | 2 |
| 1 | 2 | 3 |
| 1 | 2 | 4 |
Expected output
Your answer should return 1 row with the columns host_id, guest_id.
Starter code (Pandas (Python))
import pandas as pd
def frequent_host_guest_pairs(recording_session) -> pd.DataFrame:
# Your code here
return recording_sessionSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock