AnalystPath

Most Versatile Studios

PandasMediumMid level~10 min

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
studio_idsignup_datehome_genre
12022-01-10jazz
22022-02-15rock
32022-03-20pop
release
release_idrelease_datetrack_idstudio_id
12023-01-011021
22023-01-051031
32023-01-081011
42023-02-011042
52023-02-021022
track
track_idgenre
101jazz
102rock
103pop
104folk
105soul

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 studio

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