Asset Labels With a Three-Digit Code
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.
| asset_id | asset_label |
|---|---|
| 1 | Pallet RK402 north |
| 2 | Forklift A12B7 |
| 3 | Crate batch 90817 |
| 4 | Empty rack |
| 5 | 305 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_assetsSolve 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