AnalystPath

Unassigned Locker Numbers

PandasMediumMid level~10 min

Problem

A gym assigns sequentially numbered lockers to members, but some numbers in the run are currently empty. The `locker` DataFrame has `locker_no` (an assigned locker number) and `holder_name`.\n\nReturn every locker number between 1 and the largest assigned `locker_no` that is **not** currently assigned. Name the single output column `gap_no`.

Input data

Example rows — the live problem includes the full dataset.

locker
locker_noholder_name
1Hugo
4Iris
5Jonas

Expected output

Your answer should return 2 rows with the columns gap_no.

Starter code (Pandas (Python))

import pandas as pd

def unassigned_lockers(locker) -> pd.DataFrame:
    # Your code here
    return locker

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