How do you build a Series or DataFrame from dicts, lists, arrays, or records?

Quick Overview

Asks how to construct a pandas Series and a DataFrame from lists, NumPy arrays, dicts and lists of records. It tests whether you know where the index and column labels come from for each input, and how pandas handles missing keys, nested records and mismatched lengths.

How do you build a Series or DataFrame from dicts, lists, arrays, or records?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

How do you build a `Series` or `DataFrame` from dicts, lists, arrays, or records? ```hint Start from the shape Decide first whether the data is one labeled column or a table, then ask what the keys of a dict turn into in each case. ``` ### What a Strong Answer Covers - Building a `Series` from a list, an array, a dict and a scalar, and where the index comes from in each case - Building a `DataFrame` from a dict of lists, a list of records, a 2D array and a list of tuples - How `index=` and `columns=` behave when the input is a dict - Edge cases such as missing record keys, length mismatches and nested records ### Follow-up Questions - What does `pd.Series({"a": 1, "b": 2}, index=["b", "c"])` return, and why? - How would you turn a list of nested JSON records into a flat table? - How do you turn a `Series` into a one-column `DataFrame`, and several `Series` into one table?

Overview: Asks how to construct a pandas Series and a DataFrame from lists, NumPy arrays, dicts and lists of records. It tests whether you know where the index and column labels come from for each input, and how pandas handles missing keys, nested records and mismatched lengths.

General logo
General
Nov 25, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

How do you build a Series or DataFrame from dicts, lists, arrays, or records?

What a Strong Answer Covers Guidance

  • Building a Series from a list, an array, a dict and a scalar, and where the index comes from in each case
  • Building a DataFrame from a dict of lists, a list of records, a 2D array and a list of tuples
  • How index= and columns= behave when the input is a dict
  • Edge cases such as missing record keys, length mismatches and nested records

Follow-up Questions Guidance

  • What does pd.Series({"a": 1, "b": 2}, index=["b", "c"]) return, and why?
  • How would you turn a list of nested JSON records into a flat table?
  • How do you turn a Series into a one-column DataFrame , and several Series into one table?