Most Versatile Studios
Problem
Three DataFrames: `studio` (`studio_id`, `signup_date`, `home_genre`), `track` (`track_id`, `genre`), and `release` (`release_id`, `release_date`, `track_id`, `studio_id`). For each studio, count the number of DISTINCT tracks it released whose `genre` differs from the studio's `home_genre` ('outside' tracks). Return the studio(s) with the highest such count; ties all qualify.
Return columns `studio_id`, `outside_tracks`, sorted by `studio_id`.
Input data
Example rows — the live problem includes the full dataset.
| studio_id | signup_date | home_genre |
|---|---|---|
| 1 | 2022-01-10 | jazz |
| 2 | 2022-02-15 | rock |
| 3 | 2022-03-20 | pop |
| release_id | release_date | track_id | studio_id |
|---|---|---|---|
| 1 | 2023-01-01 | 102 | 1 |
| 2 | 2023-01-05 | 103 | 1 |
| 3 | 2023-01-08 | 101 | 1 |
| 4 | 2023-02-01 | 104 | 2 |
| 5 | 2023-02-02 | 102 | 2 |
| track_id | genre |
|---|---|
| 101 | jazz |
| 102 | rock |
| 103 | pop |
| 104 | folk |
| 105 | soul |
Expected output
Your answer should return 1 row with the columns studio_id, outside_tracks.
Starter code (Pandas (Python))
import pandas as pd
def most_versatile_studios(studio, release, track) -> pd.DataFrame:
# Your code here
return studioSolve 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