AnalystPath

Distinct Languages Spoken by Each Guide

PandasEasyJunior level~10 min

Problem

You are given a DataFrame `guide_languages` with columns `guide_id`, `language_id`, and `region_id`. The same guide can be recorded speaking the same language in several regions. Return a DataFrame with columns `guide_id` and `language_count`, where `language_count` is the number of distinct languages each guide speaks. Row order does not matter.

Input data

Example rows — the live problem includes the full dataset.

guide_languages
guide_idlanguage_idregion_id
123
124
133
211
221

Expected output

Your answer should return 2 rows with the columns guide_id, language_count.

Starter code (Pandas (Python))

import pandas as pd

def distinct_languages(guide_languages) -> pd.DataFrame:
    # Your code here
    return guide_languages

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