Skip to content

Commit 8daf274

Browse files
DOC: Clarify ExcelFile's available engine compatibility with file types in... (#34261)
* Change ExcelFile's docstring and read_excel docs in order to add information about engine compatibility and also the support of pyxlsb engine GH34237. * Doc-string clarify in read_excel and class ExcelFile * Fix read_excel docstring identation
1 parent a1eae0e commit 8daf274

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

pandas/io/excel/_base.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"""
3535
Read an Excel file into a pandas DataFrame.
3636
37-
Supports `xls`, `xlsx`, `xlsm`, `xlsb`, and `odf` file extensions
37+
Supports `xls`, `xlsx`, `xlsm`, `xlsb`, `odf`, `ods` and `odt` file extensions
3838
read from a local filesystem or URL. Supports an option to read
3939
a single sheet or a list of sheets.
4040
@@ -103,7 +103,12 @@
103103
of dtype conversion.
104104
engine : str, default None
105105
If io is not a buffer or path, this must be set to identify io.
106-
Acceptable values are None, "xlrd", "openpyxl" or "odf".
106+
Supported engines: "xlrd", "openpyxl", "odf", "pyxlsb", default "xlrd".
107+
Engine compatibility :
108+
- "xlrd" supports most old/new Excel file formats.
109+
- "openpyxl" supports newer Excel file formats.
110+
- "odf" supports OpenDocument file formats (.odf, .ods, .odt).
111+
- "pyxlsb" supports Binary Excel files.
107112
converters : dict, default None
108113
Dict of functions for converting values in certain columns. Keys can
109114
either be integers or column labels, values are functions that take one
@@ -785,17 +790,24 @@ def close(self):
785790
class ExcelFile:
786791
"""
787792
Class for parsing tabular excel sheets into DataFrame objects.
788-
Uses xlrd. See read_excel for more documentation
793+
794+
Uses xlrd engine by default. See read_excel for more documentation
789795
790796
Parameters
791797
----------
792798
io : str, path object (pathlib.Path or py._path.local.LocalPath),
793-
a file-like object, xlrd workbook or openpypl workbook.
794-
If a string or path object, expected to be a path to xls, xlsx or odf file.
799+
a file-like object, xlrd workbook or openpypl workbook.
800+
If a string or path object, expected to be a path to a
801+
.xls, .xlsx, .xlsb, .xlsm, .odf, .ods, or .odt file.
795802
engine : str, default None
796803
If io is not a buffer or path, this must be set to identify io.
797-
Acceptable values are None, ``xlrd``, ``openpyxl``, ``odf``, or ``pyxlsb``.
798-
Note that ``odf`` reads tables out of OpenDocument formatted files.
804+
Supported engines: ``xlrd``, ``openpyxl``, ``odf``, ``pyxlsb``,
805+
default ``xlrd``.
806+
Engine compatibility :
807+
- ``xlrd`` supports most old/new Excel file formats.
808+
- ``openpyxl`` supports newer Excel file formats.
809+
- ``odf`` supports OpenDocument file formats (.odf, .ods, .odt).
810+
- ``pyxlsb`` supports Binary Excel files.
799811
"""
800812

801813
from pandas.io.excel._odfreader import _ODFReader
@@ -817,7 +829,8 @@ def __init__(self, io, engine=None):
817829
raise ValueError(f"Unknown engine: {engine}")
818830

819831
self.engine = engine
820-
# could be a str, ExcelFile, Book, etc.
832+
833+
# Could be a str, ExcelFile, Book, etc.
821834
self.io = io
822835
# Always a string
823836
self._io = stringify_path(io)

0 commit comments

Comments
 (0)