Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Pandas · Function

pd.read_excel

Reads supported Excel or OpenDocument spreadsheet files into a DataFrame, from a local path, URL, bytes-like input, or file-like object. It can read one sheet or multiple sheets and offers controls for columns, types, missing values, dates, and parsing.

How it works

pandas.read_excel opens a supported Excel or OpenDocument file from a path, URL, bytes object, or file-like input and returns tabular data as a DataFrame. The selected sheet, header interpretation, columns, types, missing-value handling, date parsing, and backend can be controlled with keyword arguments.

Syntax

pandas.read_excel(io, sheet_name=0, *, header=0, names=None, index_col=None, usecols=None, dtype=None, engine=None, converters=None, true_values=None, false_values=None, skiprows=None, nrows=None, na_values=None, keep_default_na=True, na_filter=True, verbose=False, parse_dates=False, date_format=None, thousands=None, decimal='.', comment=None, skipfooter=0, storage_options=None, dtype_backend=<no_default>, engine_kwargs=None)

Parameters

NameTypeDescription
iostr, bytes, ExcelFile, xlrd.Book, path object, or file-like objectExcel file path, URL, bytes-like object, ExcelFile, xlrd.Book, path-like object, or file-like object.
sheet_namestr, int, list, or None; default 0Worksheet name, zero-based worksheet index, list of names or indices, or None for all worksheets.
headerint, list of int, or None; default 0Row containing column labels, row numbers to skip, or None for no header.
namesarray-like; default NoneColumn labels to use instead of labels read from the file.
index_colint, list of int, or None; default NoneColumn or columns to use as the DataFrame index.
usecolsint, str, list-like, or callable; default NoneColumns to parse, specified by labels, positions, ranges, a list-like object, or callable.
dtypeType name or dict of column -> type; default NoneData type for columns, or a column-to-type mapping.
enginestr or None; default NoneParser engine; when omitted, pandas chooses based on the file extension.
convertersdict; default NonePer-column conversion functions.
true_valueslist; default NoneValues interpreted as true.
false_valueslist; default NoneValues interpreted as false.
skiprowslist-like, int, or callable; default NoneRows to skip, or a callable deciding which rows to skip.

Returns

DataFrame or dict of DataFrames, depending on whether one or multiple sheets are read.

Key points

  • The function loads worksheet data into a pandas DataFrame.
  • Supported formats include legacy and modern Excel files plus OpenDocument spreadsheet formats.
  • The input may be a local file or a URL.
  • Use sheet_name to choose one worksheet or several worksheets.
  • dtype can specify one type for all columns or a mapping from column names to types.

Common mistakes

  • Install and select the appropriate external engine for the input format when pandas cannot infer or access one automatically.

Example: Read selected Excel columns

import pandas as pd
from io import BytesIO

# In practice, replace this with an .xlsx path or URL.
with pd.ExcelWriter("sales.xlsx") as writer:
    pd.DataFrame({"region": ["East", "West"], "amount": [10, 20]}).to_excel(writer, index=False)

df = pd.read_excel("sales.xlsx", sheet_name=0, usecols=["region", "amount"])
print(df)

Creates a small workbook, then reads the first sheet and selects two columns.

When to use it

Load a workbook tab

Importing a single worksheet for analysis.

Restrict imported columns

Selecting only relevant fields from a wide spreadsheet.

Read multiple sheets

Combining or comparing several worksheets.

Normalize input types

Controlling schema and missing-value interpretation at ingestion.

Interview questions

QWhat does sheet_name control?

The default sheet_name=0 reads the first worksheet and returns a DataFrame. Passing a sheet name or index selects one worksheet, while a list selects multiple sheets and returns a dictionary of DataFrames.

Follow-up: How would you inspect every worksheet? Pass sheet_name=None; the result is a dictionary keyed by worksheet names.

QHow do you read only selected columns?

usecols limits which worksheet columns are imported. It can accept column labels, Excel-style ranges, integer positions, a list-like selection, or a callable evaluated against column names.

Follow-up: How can you select columns by a naming rule? Supply a callable that returns true for the desired column labels.

QHow are labels and the index configured?

header identifies the row containing column labels, with 0 meaning the first row by default. names supplies replacement labels, and index_col chooses a column or columns for the resulting index.

Follow-up: How would you prevent an unwanted index column from becoming the index? Leave index_col=None, which is the default.

  • pandas.ExcelFile
  • pandas.read_csv
  • pandas.DataFrame.to_excel

Source: pandas.read_excel — pandas 3.0.6 documentation. Checked 2026-10-15.