AnalystPath

Hide Trial Tickets for Paying Members

PandasMediumMid level~10 min

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.

tickets
ticket_idmember_idtier
11000
21001
31011
41011
51020

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 tickets

Solve 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

Related Pandas questions