AnalystPath

Keep the Earliest Newsletter Signup

PandasEasyJunior level~10 min

Problem

A newsletter tool stores every signup. The same address can appear more than once if someone submitted the form repeatedly.

DataFrame: `signups` (from `signups.csv`)

| Column | Type |
|-------------|--------|
| signup_id | int |
| address | object |

`signup_id` is unique and is assigned in increasing order, so a smaller id means an earlier signup. Addresses are stored in lowercase.

Write a function that returns the de-duplicated list: for each distinct `address`, keep only the row with the **smallest** `signup_id`. Return columns `signup_id` and `address`, ordered by `signup_id` ascending.

Input data

Example rows — the live problem includes the full dataset.

signups
signup_idaddress
1maya@list.io
2omar@list.io
3maya@list.io

Expected output

Your answer should return 2 rows with the columns signup_id, address.

Starter code (Pandas (Python))

import pandas as pd

def first_signup(signups: pd.DataFrame) -> pd.DataFrame:
    # Your code here
    return signups

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