ExcelFile.parse(sheet_name=0, header=0, names=None, index_col=None, usecols=None, converters=None, true_values=None, false_values=None, skiprows=None, nrows=None, na_values=None, parse_dates=False, date_format=None, thousands=None, comment=None, skipfooter=0, dtype_backend=<no_default>, **kwds)[source]#

Parse specified sheet(s) into a DataFrame.

Equivalent to read_excel(ExcelFile, …) See the read_excel docstring for more info on accepted parameters.

sheet_namestr, int, list, or None, default 0

Strings are used for sheet names. Integers are used in zero-indexed sheet positions (chart sheets do not count as a sheet position). Lists of strings/integers are used to request multiple sheets. Specify None to get all worksheets.

headerint, list of int, default 0

Row (0-indexed) to use for the column labels of the parsed DataFrame. If a list of integers is passed those row positions will be combined into a MultiIndex. Use None if there is no header.

namesarray-like, default None

List of column names to use. If file contains no header row, then you should explicitly pass header=None.

index_colint, str, list of int, default None

Column (0-indexed) to use as the row labels of the DataFrame. Pass None if there is no such column. If a list is passed, those columns will be combined into a MultiIndex. If a subset of data is selected with usecols, index_col is based on the subset.

Missing values will be forward filled to allow roundtripping with to_excel for merged_cells=True. To avoid forward filling the missing values use set_index after reading the data instead of index_col.

usecolsstr, list-like, or callable, default None
  • If None, then parse all columns.

  • If str, then indicates comma separated list of Excel column letters and column ranges (e.g. “A:E” or “A,C,E:F”). Ranges are inclusive of both sides.

  • If list of int, then indicates list of column numbers to be parsed (0-indexed).

  • If list of string, then indicates list of column names to be parsed.

  • If callable, then evaluate each column name against it and parse the column if the callable returns True.

Returns a subset of the columns according to behavior above.

convertersdict, default None

Dict of functions for converting values in certain columns. Keys can either be integers or column labels, values are functions that take one input argument, the Excel cell content, and return the transformed content.

true_valueslist, default None

Values to consider as True.

false_valueslist, default None

Values to consider as False.

skiprowslist-like, int, or callable, optional

Line numbers to skip (0-indexed) or number of lines to skip (int) at the start of the file. If callable, the callable function will be evaluated against the row indices, returning True if the row should be skipped and False otherwise. An example of a valid callable argument would be lambda x: x in [0, 2].

nrowsint, default None

Number of rows to parse.

na_valuesscalar, str, list-like, or dict, default None

Additional strings to recognize as NA/NaN. If dict passed, specific per-column NA values.

parse_datesbool, list-like, or dict, default False

The behavior is as follows:

  • bool. If True -> try parsing the index.

  • list of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3 each as a separate date column.

  • list of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as a single date column.

  • dict, e.g. {{‘foo’ : [1, 3]}} -> parse columns 1, 3 as date and call result ‘foo’

If a column or index contains an unparsable date, the entire column or index will be returned unaltered as an object data type. If you don`t want to parse some cells as date just change their type in Excel to “Text”.For non-standard datetime parsing, use pd.to_datetime after pd.read_excel.

Note: A fast-path exists for iso8601-formatted dates.

date_formatstr or dict of column -> format, default None

If used in conjunction with parse_dates, will parse dates according to this format. For anything more complex, please read in as object and then apply to_datetime() as-needed.

thousandsstr, default None

Thousands separator for parsing string columns to numeric. Note that this parameter is only necessary for columns stored as TEXT in Excel, any numeric columns will automatically be parsed, regardless of display format.

commentstr, default None

Comments out remainder of line. Pass a character or characters to this argument to indicate comments in the input file. Any data between the comment string and the end of the current line is ignored.

skipfooterint, default 0

Rows at the end to skip (0-indexed).

dtype_backend{{‘numpy_nullable’, ‘pyarrow’}}, default ‘numpy_nullable’

Back-end data type applied to the resultant DataFrame (still experimental). Behaviour is as follows:

  • "numpy_nullable": returns nullable-dtype-backed DataFrame (default).

  • "pyarrow": returns pyarrow-backed nullable ArrowDtype DataFrame.

Added in version 2.0.

**kwdsdict, optional

Arbitrary keyword arguments passed to excel engine.

DataFrame or dict of DataFrames

DataFrame from the passed in Excel file.

See also


Read an Excel sheet values (xlsx) file into DataFrame.


Read a comma-separated values (csv) file into DataFrame.


Read a table of fixed-width formatted lines into DataFrame.


>>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=["A", "B", "C"])
>>> df.to_excel("myfile.xlsx")  
>>> file = pd.ExcelFile("myfile.xlsx")  
>>> file.parse()