Pandas Read Excel: Load a Workbook

A Python analysis can start with the values stored in an Excel worksheet. pandas.read_excel() reads worksheet values into a DataFrame, a labeled table with rows and columns.

I’ll show how to read one sheet or collect several, and how to match the header and selected columns to the sheet.

TL;DR

Use pandas.read_excel() with a workbook path and sheet_name to load one worksheet into a DataFrame, the default result, while None or a list returns a dictionary of DataFrames.

  • Install pandas and the engine package for your workbook format in the same Python environment.
  • Choose sheet_name, then limit the read with usecols, header or dtype when the workbook needs it.
  • Keep IDs as text in Excel when leading zeros are part of the value.

What Is pandas.read_excel?

pandas.read_excel() reads worksheet values into a DataFrame, a labeled table with rows and columns.

For xlsx and xlsm, pandas 3.1.1 lists openpyxl or calamine, for xls xlrd or calamine, for xlsb pyxlsb or calamine, and for OpenDocument odf or calamine. The docs mark the xlsx and xlsm default for deprecation in favor of calamine.

Choose a DataFrame for filtering or summarizing tables. Use openpyxl for workbook objects or read-only row iteration. The xlsx example sets that engine explicitly because it is installed for the file format.

How to Read an Excel Workbook with pandas

Pass the workbook path and select the worksheet and columns the next step needs.

Step 1: Install the reader packages

Install pandas and the xlsx engine in the active environment.

.venv/bin/python -m pip install pandas openpyxl

The environment reports these installed versions:

Requirement already satisfied: pandas in ./.venv/lib/python3.11/site-packages (3.1.1)
Requirement already satisfied: openpyxl in ./.venv/lib/python3.11/site-packages (3.1.5)
Requirement already satisfied: numpy>=2.0.2 in ./.venv/lib/python3.11/site-packages (from pandas) (2.4.6)
Requirement already satisfied: python-dateutil>=2.9.0 in ./.venv/lib/python3.11/site-packages (from pandas) (4.0.0)
Requirement already satisfied: et-xmlfile in ./.venv/lib/python3.11/site-packages (from openpyxl) (2.0.0)
Requirement already satisfied: tzdata in ./.venv/lib/python3.11/site-packages (from python-dateutil>=2.9.0->pandas) (2026.6)
Pip confirms pandas 3.1.1 and openpyxl 3.1.5 are installed
The active virtual environment has pandas and the openpyxl engine.

The example uses pandas 3.1.1 and openpyxl 3.1.5.

Step 2: Save the reader example and select a sheet

Save the program as pd_read_excel_demo.py. ExcelFile.sheet_names lists tabs, and sheet_name selects one.

from pathlib import Path

import pandas as pd

workbook = Path("orders.xlsx")
with pd.ExcelWriter(workbook, engine="openpyxl") as writer:
    pd.DataFrame(
        {
            "Order ID": ["00421", "00422"],
            "Region": ["West", "East"],
            "Amount": [125.5, 89.0],
        }
    ).to_excel(writer, sheet_name="Orders", index=False)
    pd.DataFrame({"Product": ["Notebook"], "Units": [3]}).to_excel(
        writer, sheet_name="Returns", index=False
    )

with pd.ExcelFile(workbook, engine="openpyxl") as excel_file:
    print("Sheets:", excel_file.sheet_names)

orders = pd.read_excel(
    workbook,
    sheet_name="Orders",
    usecols=["Order ID", "Amount"],
    dtype={"Order ID": "string"},
    engine="openpyxl",
)
print(orders.to_string(index=False))

Run the saved file with the interpreter in your environment:

.venv/bin/python pd_read_excel_demo.py

I ran it and got these sheet names and columns:

Sheets: ['Orders', 'Returns']
Order ID  Amount
   00421   125.5
   00422    89.0
Pandas lists Orders and Returns sheets and prints selected order IDs and amounts
The workbook tabs and the two selected columns appear in the terminal.

The result contains the two requested columns. The text IDs retain their leading zeros, and Region is omitted.

Step 3: Choose one sheet or collect several

Use a sheet name or zero-based position to return one DataFrame. A list selects chosen tabs and None reads all tabs, each returning a dictionary of DataFrames. Select a key when later code needs one table.

Step 4: Match headers and columns to the sheet

Set header to the zero-based label row, or use header=None with names when there is no header. usecols accepts Excel letters, positions or parsed labels. Label selection depends on header, and the result may need reordering.

Use skiprows to pass title rows, nrows to limit parsed rows and dtype to set column types. Blanks become missing values, which na_values or keep_default_na can configure.

For merged-cell indexes, read without index_col and call set_index() later if forward-filling would change needed values.

Handle pandas.read_excel Edge Cases

Check the path, engine and stored cell value when a read fails or an identifier changes.

SymptomCheck or fix
FileNotFoundErrorCorrect the filename, extension or working-directory path.
Missing engineInstall a format-compatible package in the active environment.
Lost leading zerosKeep identifier cells as text in the workbook.
Large workbookLimit columns and rows, or iterate with openpyxl read-only mode.

I requested a workbook that does not exist and got this message:

import pandas as pd

try:
    pd.read_excel("missing_orders.xlsx", engine="openpyxl")
except FileNotFoundError as error:
    print(f"{type(error).__name__}: {error}")
.venv/bin/python missing_workbook_probe.py
FileNotFoundError: [Errno 2] No such file or directory: 'missing_orders.xlsx'
FileNotFoundError for missing_orders.xlsx raised by pandas read_excel
The error names the workbook path that Python could not find.

Check the spelling, extension and current working directory. Relative paths use that directory, which may differ from the script’s folder.

I read text and numeric IDs with dtype set to string:

from openpyxl import Workbook
import pandas as pd

workbook = Workbook()
sheet = workbook.active
sheet.title = "IDs"
sheet.append(["Kind", "ID"])
sheet.append(["Text ID", "00421"])
sheet.append(["Formatted number", 421])
sheet["B3"].number_format = "00000"
workbook.save("id_formats.xlsx")

ids = pd.read_excel(
    "id_formats.xlsx",
    dtype={"ID": "string"},
    engine="openpyxl",
)
for row in ids.itertuples(index=False):
    print(f"{row.Kind}: {row.ID!r}")
.venv/bin/python excel_id_formats_probe.py
Text ID: '00421'
Formatted number: '421'
Pandas keeps zeros in a text ID but reads a formatted numeric ID as 421
The text cell retains its zeros while the formatted numeric cell returns 421.

The text cell retained 00421. The numeric cell returned 421 because its zeros exist only in Excel’s display format.

read_excel() has no chunksize parameter. I tested it and got a TypeError:

import pandas as pd

try:
    pd.read_excel("orders.xlsx", chunksize=2)
except TypeError as error:
    print(f"{type(error).__name__}: {error}")
.venv/bin/python excel_chunksize_probe.py
TypeError: read_excel() got an unexpected keyword argument 'chunksize'
TypeError showing read_excel does not accept chunksize
The pandas reader rejects chunksize rather than returning batches.

Use nrows to limit a parsed result, not to stream it. For row iteration, openpyxl supports read_only=True and the workbook must be closed afterward. pandas also accepts an accessible workbook URL or file-like object as input.

Conclusion

Select the worksheet, then match its header and column types to your task. Check the pandas.read_excel API reference and pandas I/O guide for parameter details.

For workbook objects, see OpenPyXL in Python. After loading a table, try Pandas Melt and Pivot Data.

FAQ

The spreadsheet application is separate from pandas’ Python reader engine.

Does pandas need Microsoft Excel installed?

No. Install a compatible Python engine, such as openpyxl, alongside pandas.

Can I read an Excel file from a URL?

Yes, if the URL is accessible and required network or storage dependencies are installed.

What should I use when a workbook is too large to load as a DataFrame?

Limit columns or rows, or use openpyxl read-only mode for iteration. read_excel has no chunksize iterator.

Ninad
Ninad

A Python and PHP developer turned writer out of passion. Over the last 6+ years, he has written for brands including DigitalOcean, DreamHost, Hostinger, and many others. When not working, you'll find him tinkering with open-source projects, vibe coding, or on a mountain trail, completely disconnected from tech.

Articles: 136