The Create a DataFrame from List interview question is a fundamental task in Python data engineering. You are given a 2D list (or a list of lists) where each inner list represents a row of data. You need to convert this into a pandas DataFrame object with specified column names. This is typically the first step in any data analysis or machine learning pipeline using the pandas library.
Companies like Uber, Microsoft, and Amazon ask the Create a DataFrame from List coding problem to verify a candidate's basic competency with pandas, the industry-standard library for data manipulation in Python. It evaluates whether you understand how to structure raw data into a tabular format and how to interact with common library constructors. It's an "Easy" difficulty question that serves as a baseline check for data-centric roles.
This problem doesn't use a traditional algorithm but rather follows a Library API usage pattern.
pd.DataFrame() constructor.data).columns).Input list: [[1, 'Alice'], [2, 'Bob']], Columns: ['student_id', 'name']
[1, 'Alice'] as the first row.[2, 'Bob'] as the second row.import pandas as pd statement.Pandas is a must-know for data science. Beyond just creating a DataFrame, practice basic operations like head(), describe(), and selecting columns, as these are usually the follow-up questions in an interview.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Kids With the Greatest Number of Candies | Easy | Solve | |
| Binary Tree Inorder Traversal | Easy | Solve | |
| Minimum Depth of Binary Tree | Easy | Solve | |
| Build Array from Permutation | Easy | Solve | |
| Combine Two Tables | Easy | Solve |