Skip to content

Commit 70fc174

Browse files
authored
DOC: Update docstring for read_excel (#56543)
1 parent 2522b0a commit 70fc174

File tree

2 files changed

+17
-34
lines changed

2 files changed

+17
-34
lines changed

doc/source/user_guide/io.rst

+7-12
Original file line numberDiff line numberDiff line change
@@ -3471,20 +3471,15 @@ saving a ``DataFrame`` to Excel. Generally the semantics are
34713471
similar to working with :ref:`csv<io.read_csv_table>` data.
34723472
See the :ref:`cookbook<cookbook.excel>` for some advanced strategies.
34733473

3474-
.. warning::
3475-
3476-
The `xlrd <https://xlrd.readthedocs.io/en/latest/>`__ package is now only for reading
3477-
old-style ``.xls`` files.
3474+
.. note::
34783475

3479-
Before pandas 1.3.0, the default argument ``engine=None`` to :func:`~pandas.read_excel`
3480-
would result in using the ``xlrd`` engine in many cases, including new
3481-
Excel 2007+ (``.xlsx``) files. pandas will now default to using the
3482-
`openpyxl <https://openpyxl.readthedocs.io/en/stable/>`__ engine.
3476+
When ``engine=None``, the following logic will be used to determine the engine:
34833477

3484-
It is strongly encouraged to install ``openpyxl`` to read Excel 2007+
3485-
(``.xlsx``) files.
3486-
**Please do not report issues when using ``xlrd`` to read ``.xlsx`` files.**
3487-
This is no longer supported, switch to using ``openpyxl`` instead.
3478+
- If ``path_or_buffer`` is an OpenDocument format (.odf, .ods, .odt),
3479+
then `odf <https://pypi.org/project/odfpy/>`_ will be used.
3480+
- Otherwise if ``path_or_buffer`` is an xls format, ``xlrd`` will be used.
3481+
- Otherwise if ``path_or_buffer`` is in xlsb format, ``pyxlsb`` will be used.
3482+
- Otherwise ``openpyxl`` will be used.
34883483

34893484
.. _io.excel_reader:
34903485

pandas/io/excel/_base.py

+10-22
Original file line numberDiff line numberDiff line change
@@ -160,36 +160,24 @@
160160
If converters are specified, they will be applied INSTEAD
161161
of dtype conversion.
162162
If you use ``None``, it will infer the dtype of each column based on the data.
163-
engine : str, default None
163+
engine : {{'openpyxl', 'calamine', 'odf', 'pyxlsb', 'xlrd'}}, default None
164164
If io is not a buffer or path, this must be set to identify io.
165-
Supported engines: "xlrd", "openpyxl", "odf", "pyxlsb", "calamine".
166165
Engine compatibility :
167166
168-
- ``xlr`` supports old-style Excel files (.xls).
169167
- ``openpyxl`` supports newer Excel file formats.
170-
- ``odf`` supports OpenDocument file formats (.odf, .ods, .odt).
171-
- ``pyxlsb`` supports Binary Excel files.
172168
- ``calamine`` supports Excel (.xls, .xlsx, .xlsm, .xlsb)
173169
and OpenDocument (.ods) file formats.
170+
- ``odf`` supports OpenDocument file formats (.odf, .ods, .odt).
171+
- ``pyxlsb`` supports Binary Excel files.
172+
- ``xlrd`` supports old-style Excel files (.xls).
174173
175-
.. versionchanged:: 1.2.0
176-
The engine `xlrd <https://xlrd.readthedocs.io/en/latest/>`_
177-
now only supports old-style ``.xls`` files.
178-
When ``engine=None``, the following logic will be
179-
used to determine the engine:
180-
181-
- If ``path_or_buffer`` is an OpenDocument format (.odf, .ods, .odt),
182-
then `odf <https://pypi.org/project/odfpy/>`_ will be used.
183-
- Otherwise if ``path_or_buffer`` is an xls format,
184-
``xlrd`` will be used.
185-
- Otherwise if ``path_or_buffer`` is in xlsb format,
186-
``pyxlsb`` will be used.
187-
188-
.. versionadded:: 1.3.0
189-
- Otherwise ``openpyxl`` will be used.
190-
191-
.. versionchanged:: 1.3.0
174+
When ``engine=None``, the following logic will be used to determine the engine:
192175
176+
- If ``path_or_buffer`` is an OpenDocument format (.odf, .ods, .odt),
177+
then `odf <https://pypi.org/project/odfpy/>`_ will be used.
178+
- Otherwise if ``path_or_buffer`` is an xls format, ``xlrd`` will be used.
179+
- Otherwise if ``path_or_buffer`` is in xlsb format, ``pyxlsb`` will be used.
180+
- Otherwise ``openpyxl`` will be used.
193181
converters : dict, default None
194182
Dict of functions for converting values in certain columns. Keys can
195183
either be integers or column labels, values are functions that take one

0 commit comments

Comments
 (0)