Data structures & formats · reviewed in July 2026
DataFrame
A DataFrame is a two-dimensional, table-like data structure — similar to a spreadsheet — with labeled rows and named columns that can each hold a different data type. It is the central object of Python's pandas library and the usual way to load, clean and analyze tabular data.
import pandas as pd
df = pd.DataFrame({
"customer": ["Ana", "Luis"],
"total": [120.5, 89.0],
})
df["total"].mean()Frequently asked questions
What's the difference between a DataFrame and a Series?
A pandas Series is a single labeled column (a one-dimensional array), whereas a DataFrame is a collection of Series that share the same row index. Each column of a DataFrame is, in effect, a Series.
How is a DataFrame like a spreadsheet?
Both organize data into rows and columns and let you filter, sort and aggregate. The difference is that a DataFrame is manipulated with code, which makes the analysis reproducible and scalable to millions of rows.
How do you create a DataFrame in pandas?
You can build one from a dictionary of lists, a list of dictionaries, or by reading a file with functions like pd.read_csv. Each key or header becomes a named column.