Python
#38

Flatten Nested List Columns with df.explode() in Pandas

Easy
Interview Question #38

Given an order table where `product_ids` contains a list of items `[101, 102, 103]`, unnest the list so that each product appears on its own row with duplicate order details.

Input Table: orders
2 rows preview
order_idproduct_ids
1101,102
2103
Expected Output Structure3 rows
order_idproduct_ids
1101
1102
2103
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