AnalystPath

Podcast Search Relevance and Weak-Hit Rate

PandasEasyJunior level~10 min

Problem

You are given a DataFrame `searchhits` loaded from `searchhits.csv` with columns `search_term`, `episode`, `slot`, and `stars`. Each row is one episode that appeared in the results for a search term: `slot` (1 = top) is where it appeared and `stars` (1 to 5) is the score a listener gave it. A search term can have many rows.

For each `search_term`, compute two numbers: `relevance`, the average of `stars / slot` across that term's rows, rounded to 2 decimals; and `weak_hit_pct`, the percentage of that term's rows whose `stars` is below 3, rounded to 2 decimals. Output columns: `search_term`, `relevance`, `weak_hit_pct`.

Input data

Example rows — the live problem includes the full dataset.

searchhits
search_termepisodeslotstars
historyThe Roman Road15
historyLost Empires25
historyFiller Clip2001
comedyLate Set52
comedyOpen Mic33

Expected output

Your answer should return 2 rows with the columns search_term, relevance, weak_hit_pct.

Starter code (Pandas (Python))

import pandas as pd

def search_relevance(searchhits) -> pd.DataFrame:
    # Your code here
    return searchhits

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