AnalystPath

Counting Package Registries

PandasEasyJunior level~10 min

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.

packages
pkg_idcoordinate
336hwkiy@crates.io
489adcmaf@maven.org
449vrzmwyum@pypi.org
95tof@crates.io
320jxhbagkpm@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 packages

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