AnalystPath

Tickets Mentioning Key Words

PandasMediumMid level~10 min

Problem

You are given one DataFrame, `support_note`, loaded from `support_note.csv` with columns `note_ref` (the primary key) and `body` (the free-text body of one support ticket).

Count how many ticket bodies contain the word `urgent` and how many contain the word `refund`, where each must appear as a **standalone word** (surrounded by spaces or at the very start/end of the body), not merely as part of a longer word such as 'refundable'. Return two rows with columns `word` and `tally`: first the row for `urgent`, then the row for `refund`.

Input data

Example rows — the live problem includes the full dataset.

support_note
note_refbody
N-1Customer flagged this as urgent and asked for a refund of the deposit.
N-2They want a refund but it is not urgent at all.
N-3The item is refundable within thirty days, no action needed.
N-4urgent

Expected output

Your answer should return 2 rows with the columns word, tally.

Starter code (Pandas (Python))

import pandas as pd

def count_keyword_mentions(support_note) -> pd.DataFrame:
    # Your code here
    return support_note

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