AnalystPath

Asset Labels With a Three-Digit Code

PandasEasyJunior level~10 min

Problem

You are given one DataFrame `warehouse_assets` with columns `asset_id` and `asset_label` (a free-text label that may contain a numeric code).

Return every asset whose `asset_label` contains a run of **exactly three** consecutive digits. A run of two digits (like `42`) or four or more digits (like `5500`) does not count — only a group that is precisely three digits long, with a non-digit (or the start/end of the string) on each side. Missing labels never match.

Return columns `asset_id` and `asset_label`, ordered by `asset_id` ascending.

Input data

Example rows — the live problem includes the full dataset.

warehouse_assets
asset_idasset_label
1Pallet RK402 north
2Forklift A12B7
3Crate batch 90817
4Empty rack
5305 dock door

Expected output

Your answer should return 3 rows with the columns asset_id, asset_label.

Starter code (Pandas (Python))

import pandas as pd

def assets_with_three_digit_code(warehouse_assets) -> pd.DataFrame:
    # Your code here
    return warehouse_assets

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