Hide Trial Tickets for Paying Members
Problem
A help desk stores support tickets in a DataFrame `tickets` (loaded from a CSV) with columns `(ticket_id, member_id, tier)`. `tier` is 0 for a paid ticket and 1 for a trial ticket; `ticket_id` is unique.
Return the tickets to display, with columns `ticket_id`, `member_id`, `tier`, in any order:
- If a member has at least one paid ticket (`tier == 0`), do NOT include any of that member's trial tickets (`tier == 1`).
- Otherwise, include all of that member's tickets.
Input data
Example rows — the live problem includes the full dataset.
| ticket_id | member_id | tier |
|---|---|---|
| 1 | 100 | 0 |
| 2 | 100 | 1 |
| 3 | 101 | 1 |
| 4 | 101 | 1 |
| 5 | 102 | 0 |
Expected output
Your answer should return 4 rows with the columns ticket_id, member_id, tier.
Starter code (Pandas (Python))
import pandas as pd
def hide_trial_tickets_for_paying_members(tickets) -> pd.DataFrame:
# Your code here
return ticketsSolve 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