Counting Package Registries
Problem
A DataFrame `packages` lists software dependencies. Each row has a `pkg_id` and a `coordinate` string written as `name@registry` (for example `parser@npmjs.org`). The part before the `@` is the package name; the part after the `@` is the registry host.
Keep only coordinates whose registry host ends in `.org`. For those, extract the registry host and count how many packages come from each one. Return a DataFrame with columns `registry` (the host after the `@`) and `pkg_count` (the number of packages from that registry), ordered by `registry` ascending.
Input data
Example rows — the live problem includes the full dataset.
| pkg_id | coordinate |
|---|---|
| 336 | hwkiy@crates.io |
| 489 | adcmaf@maven.org |
| 449 | vrzmwyum@pypi.org |
| 95 | tof@crates.io |
| 320 | jxhbagkpm@nuget.net |
Expected output
Your answer should return 2 rows with the columns registry, pkg_count.
Starter code (Pandas (Python))
import pandas as pd
def count_org_registries(packages) -> pd.DataFrame:
# Your code here
return packagesSolve 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