Python
#29

Extract Structured Features with .str.extract() in Pandas

Medium
Interview 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: products
2 rows preview
title
Samsung Galaxy S24 - 256GB - Phantom Black
Apple iPhone 15 - 128GB - Blue
Expected Output Structure2 rows
storage_gbcolor
256Phantom Black
128Blue
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

Click "Run & Test" to execute your Pandas code against the test assertions.

Chat with us