Subscriber Count per Channel
Problem
You are given a DataFrame `subscription` with columns `channel_id` and `subscriber_id`.
For each channel, return how many subscribers it has. Order the result by `channel_id`. Output columns: `channel_id`, `subscriber_count`.
Input data
Example rows — the live problem includes the full dataset.
subscription
| channel_id | subscriber_id |
|---|---|
| 1 | 10 |
| 1 | 11 |
| 1 | 12 |
| 2 | 10 |
| 2 | 13 |
Expected output
Your answer should return 2 rows with the columns channel_id, subscriber_count.
Starter code (Pandas (Python))
import pandas as pd
def subscriber_count_per_channel(subscription) -> pd.DataFrame:
# Your code here
return subscriptionSolve 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