Keep the Earliest Newsletter Signup
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.
| signup_id | address |
|---|---|
| 1 | maya@list.io |
| 2 | omar@list.io |
| 3 | maya@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 signupsSolve 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