Python
All Top Python Interview Questions#29
Extract Structured Features with .str.extract() in Pandas
MediumInterview Question #29
Given a column of product titles like `'Samsung Galaxy S24 - 256GB - Phantom Black'`, extract `storage_gb` (e.g. 256) and `color` into separate columns using regex capture groups.
Input Table: df
2 rows preview| title |
|---|
| Samsung Galaxy S24 - 256GB - Phantom Black |
| Apple iPhone 15 - 128GB - Blue |
Expected Output Structure2 rows
| storage_gb | color |
|---|---|
| 256 | Phantom Black |
| 128 | Blue |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
Python 3.10 (Pandas)
Environment Ready
Starting the real Python + pandas runtime (one-time download)…