How to Convert a List to a Pandas DataFrame in Python

To convert a list to a pandas DataFrame, pass it to pd.DataFrame() and name the columns with columns=. A flat list gives you one column. A list of lists gives you one row per inner list:

import pandas as pd
df = pd.DataFrame([["Emily", 249.99], ["James", 89.50]], columns=["customer", "total_usd"])

The outputs below came from real runs on Python 3.12.5 with pandas 3.0.6, so the tables and dtypes are exactly what you’ll get.

Convert a flat list to a one-column DataFrame

A plain list of values becomes a single column. Give it a name with columns, or pandas just calls it 0:

import pandas as pd

prices = [19.99, 4.50, 129.00, 7.25]

df = pd.DataFrame(prices, columns=["price_usd"])
print(df)
print(pd.DataFrame([prices]).shape)   # wrapped in [] -> one row, four columns

Output:

   price_usd
0      19.99
1       4.50
2     129.00
3       7.25
(1, 4)

Need the values across one row instead? Wrap the list in another list, as the shape (1, 4) shows. If you already have a Series, see converting a pandas Series to a DataFrame.

Convert a list of lists to a pandas DataFrame (one row each)

This is the shape you’ll meet most. Every inner list turns into a row, and its positions line up with columns:

import pandas as pd

orders = [
    ["A-1001", "Emily",  "Austin",  249.99],
    ["A-1002", "James",  "Denver",   89.50],
    ["A-1003", "Olivia", "Seattle", 512.00],
]

df = pd.DataFrame(orders, columns=["order_id", "customer", "city", "total_usd"])
print(df)
print(df.dtypes)

ragged = [["A-1004", "Noah", "Boston"], ["A-1005", "Ava"]]
print(pd.DataFrame(ragged, columns=["order_id", "customer", "city"]))

Output:

  order_id customer     city  total_usd
0   A-1001    Emily   Austin     249.99
1   A-1002    James   Denver      89.50
2   A-1003   Olivia  Seattle     512.00
order_id         str
customer         str
city             str
total_usd    float64
dtype: object
  order_id customer    city
0   A-1004     Noah  Boston
1   A-1005      Ava     NaN
Command Prompt output of a Python list of lists converted to a pandas DataFrame of orders, plus a short row filled with NaN
Three order rows become a table with float totals; the short second row in the ragged list gets NaN for its city.

A short row doesn’t raise an error; pandas fills the gap with a missing value. If you build the rows yourself, initializing a list of a fixed size in Python keeps every row the same length.

How do I turn several lists into DataFrame columns?

When each list is a column, use a dictionary of lists. zip() gives the same table by pairing the values into rows first:

import pandas as pd

states = ["Texas", "Ohio", "Utah"]
sales = [1520.75, 980.40, 615.00]

by_dict = pd.DataFrame({"state": states, "sales_usd": sales})
by_zip = pd.DataFrame(list(zip(states, sales)), columns=["state", "sales_usd"])
print(by_dict)
print(by_dict.equals(by_zip))

try:
    pd.DataFrame({"state": states, "sales_usd": sales[:2]})
except ValueError as e:
    print("ValueError:", e)

print(pd.DataFrame(list(zip(states, sales[:2])), columns=["state", "sales_usd"]))

Output:

   state  sales_usd
0  Texas    1520.75
1   Ohio     980.40
2   Utah     615.00
True
ValueError: All arrays must be of the same length
   state  sales_usd
0  Texas    1520.75
1   Ohio     980.40
Command Prompt output of Python lists turned into DataFrame columns with a dict and zip, plus the ValueError for unequal lengths
Both methods build the same table. With a list that’s one item short, the dict raises a ValueError while zip() quietly drops Utah.

I prefer the dictionary because it fails loudly on mismatched lists. More on mappings is in creating a pandas DataFrame from a dictionary.

Convert a list of dictionaries to a DataFrame

Records from JSON usually arrive as a list of dictionaries. The keys become columns, and a key that’s missing from one record turns into NaN:

import pandas as pd

signups = [
    {"name": "Emily", "plan": "Pro", "seats": 5},
    {"name": "James", "plan": "Basic"},
    {"name": "Olivia", "plan": "Pro", "seats": 12},
]
df = pd.DataFrame(signups)
print(df)
print(df.dtypes)

Output:

     name   plan  seats
0   Emily    Pro    5.0
1   James  Basic    NaN
2  Olivia    Pro   12.0
name         str
plan         str
seats    float64
dtype: object
Command Prompt output of a Python list of dictionaries converted to a pandas DataFrame with NaN for a missing seats key
James has no seats key, so his cell shows NaN and the whole column becomes float64.

That’s why seats became floats. Nested keys and from_records() are covered in building a pandas DataFrame from a list of dictionaries.

Fix column dtypes after converting a list to a DataFrame

Lists read from text often hold numbers and dates as strings. Math and date filters won’t work until you convert them:

import pandas as pd

rows = [["2026-01-15", "49.99"], ["2026-02-03", "120.00"], ["2026-03-21", "15.25"]]
df = pd.DataFrame(rows, columns=["order_date", "amount_usd"])
print(df.dtypes)

df["order_date"] = pd.to_datetime(df["order_date"])
df["amount_usd"] = pd.to_numeric(df["amount_usd"])
print(df.dtypes)

Output:

order_date    str
amount_usd    str
dtype: object
order_date    datetime64[us]
amount_usd           float64
dtype: object
Command Prompt output of pandas DataFrame dtypes before and after to_datetime and to_numeric on columns built from a list
Both columns start as str, then become datetime64 and float64.

Once the types are right, writing the pandas DataFrame to a CSV file keeps a clean copy.

If you’re working through pandas, try these next:

Frequently asked questions

How do I convert a list to a pandas DataFrame?

Call pd.DataFrame(my_list, columns=["name"]).

How do I convert two lists into a DataFrame?

Use a dictionary of lists: pd.DataFrame({"a": list1, "b": list2}).

What happens if my lists have different lengths?

The dictionary form raises ValueError: All arrays must be of the same length. zip() silently cuts to the shortest list.

How do I make a list one row instead of one column?

Wrap it in another list: pd.DataFrame([my_list]).

Why are my numbers stored as text in the DataFrame?

The list held strings, so pandas keeps a text dtype (str in pandas 3, object before). Convert the column with pd.to_numeric(), or dates with pd.to_datetime().

Where is the DataFrame constructor documented?

See pandas.DataFrame in the pandas docs.