Tickets Mentioning Key Words
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.
| note_ref | body |
|---|---|
| N-1 | Customer flagged this as urgent and asked for a refund of the deposit. |
| N-2 | They want a refund but it is not urgent at all. |
| N-3 | The item is refundable within thirty days, no action needed. |
| N-4 | urgent |
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_noteSolve 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