Standout Clinics
Problem
A health network records monthly metrics for each clinic in a DataFrame `metric` (`metric.csv`).
```text
+-------------+--------+
| Column | Type |
+-------------+--------+
| clinic_id | int |
| metric_name | object |
| tally | int |
+-------------+--------+
```
`(clinic_id, metric_name)` is unique. Each row holds one clinic's tally for one metric (such as `'visits'`, `'referrals'`, or `'screenings'`).
Write a function that finds all standout clinics. A clinic is a standout when it beats the network-wide average for more than one metric, where beating means its tally for that metric is strictly greater than the average tally of that same metric across all clinics. Return a single column `clinic_id` in any order.
Input data
Example rows — the live problem includes the full dataset.
| clinic_id | metric_name | tally |
|---|---|---|
| 1 | referrals | 7 |
| 3 | referrals | 3 |
| 1 | visits | 11 |
| 2 | visits | 7 |
| 3 | visits | 6 |
Expected output
Your answer should return 1 row with the columns clinic_id.
Starter code (Pandas (Python))
import pandas as pd
def standout_clinics(metric: pd.DataFrame) -> pd.DataFrame:
# Your code here
return metricSolve 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