Extract Email Domains and Count Users
Problem
**[Classic — string operations]**
Extract the domain (everything after `@`) from each user's email and return
the count of users per domain.
Return columns: `domain`, `user_count`. Order by count desc, then domain.
Input data
Example rows — the live problem includes the full dataset.
users
| user_id | |
|---|---|
| 1 | alice@gmail.com |
| 2 | bob@gmail.com |
| 3 | carol@yahoo.com |
| 4 | dave@gmail.com |
| 5 | eve@outlook.com |
Expected output
Your answer should return 3 rows with the columns domain, user_count.
Starter code (Pandas (Python))
import pandas as pd
def extract_domains(users: pd.DataFrame) -> pd.DataFrame:
# Your code here
return usersSolve 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