AnalystPath

Standout Clinics

PandasMediumMid level~10 min

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.

metric
clinic_idmetric_nametally
1referrals7
3referrals3
1visits11
2visits7
3visits6

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 metric

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