Skip to content

Commit 0dd6954

Browse files
authored
DOC: Improve io/excel/_base.py (#56453)
* Improve error message and add test * Remove empty line * update * Fix line length * Update test_indexing.py * Add spaces * Remove changes in test_indexing.py * Update base.py
1 parent 5ad2251 commit 0dd6954

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

pandas/io/excel/_base.py

+28-27
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
)
8787
_read_excel_doc = (
8888
"""
89-
Read an Excel file into a pandas DataFrame.
89+
Read an Excel file into a ``pandas`` ``DataFrame``.
9090
9191
Supports `xls`, `xlsx`, `xlsm`, `xlsb`, `odf`, `ods` and `odt` file extensions
9292
read from a local filesystem or URL. Supports an option to read
@@ -112,7 +112,7 @@
112112
Strings are used for sheet names. Integers are used in zero-indexed
113113
sheet positions (chart sheets do not count as a sheet position).
114114
Lists of strings/integers are used to request multiple sheets.
115-
Specify None to get all worksheets.
115+
Specify ``None`` to get all worksheets.
116116
117117
Available cases:
118118
@@ -121,7 +121,7 @@
121121
* ``"Sheet1"``: Load sheet with name "Sheet1"
122122
* ``[0, 1, "Sheet5"]``: Load first, second and sheet named "Sheet5"
123123
as a dict of `DataFrame`
124-
* None: All worksheets.
124+
* ``None``: All worksheets.
125125
126126
header : int, list of int, default 0
127127
Row (0-indexed) to use for the column labels of the parsed
@@ -155,21 +155,21 @@
155155
Returns a subset of the columns according to behavior above.
156156
dtype : Type name or dict of column -> type, default None
157157
Data type for data or columns. E.g. {{'a': np.float64, 'b': np.int32}}
158-
Use `object` to preserve data as stored in Excel and not interpret dtype,
159-
which will necessarily result in `object` dtype.
158+
Use ``object`` to preserve data as stored in Excel and not interpret dtype,
159+
which will necessarily result in ``object`` dtype.
160160
If converters are specified, they will be applied INSTEAD
161161
of dtype conversion.
162-
If you use `None`, it will infer the dtype of each column based on the data.
162+
If you use ``None``, it will infer the dtype of each column based on the data.
163163
engine : str, default None
164164
If io is not a buffer or path, this must be set to identify io.
165165
Supported engines: "xlrd", "openpyxl", "odf", "pyxlsb", "calamine".
166166
Engine compatibility :
167167
168-
- "xlrd" supports old-style Excel files (.xls).
169-
- "openpyxl" supports newer Excel file formats.
170-
- "odf" supports OpenDocument file formats (.odf, .ods, .odt).
171-
- "pyxlsb" supports Binary Excel files.
172-
- "calamine" supports Excel (.xls, .xlsx, .xlsm, .xlsb)
168+
- ``xlr`` supports old-style Excel files (.xls).
169+
- ``openpyxl`` supports newer Excel file formats.
170+
- ``odf`` supports OpenDocument file formats (.odf, .ods, .odt).
171+
- ``pyxlsb`` supports Binary Excel files.
172+
- ``calamine`` supports Excel (.xls, .xlsx, .xlsm, .xlsb)
173173
and OpenDocument (.ods) file formats.
174174
175175
.. versionchanged:: 1.2.0
@@ -215,34 +215,34 @@
215215
+ """'.
216216
keep_default_na : bool, default True
217217
Whether or not to include the default NaN values when parsing the data.
218-
Depending on whether `na_values` is passed in, the behavior is as follows:
218+
Depending on whether ``na_values`` is passed in, the behavior is as follows:
219219
220-
* If `keep_default_na` is True, and `na_values` are specified, `na_values`
221-
is appended to the default NaN values used for parsing.
222-
* If `keep_default_na` is True, and `na_values` are not specified, only
220+
* If ``keep_default_na`` is True, and ``na_values`` are specified,
221+
``na_values`` is appended to the default NaN values used for parsing.
222+
* If ``keep_default_na`` is True, and ``na_values`` are not specified, only
223223
the default NaN values are used for parsing.
224-
* If `keep_default_na` is False, and `na_values` are specified, only
225-
the NaN values specified `na_values` are used for parsing.
226-
* If `keep_default_na` is False, and `na_values` are not specified, no
224+
* If ``keep_default_na`` is False, and ``na_values`` are specified, only
225+
the NaN values specified ``na_values`` are used for parsing.
226+
* If ``keep_default_na`` is False, and ``na_values`` are not specified, no
227227
strings will be parsed as NaN.
228228
229-
Note that if `na_filter` is passed in as False, the `keep_default_na` and
230-
`na_values` parameters will be ignored.
229+
Note that if `na_filter` is passed in as False, the ``keep_default_na`` and
230+
``na_values`` parameters will be ignored.
231231
na_filter : bool, default True
232232
Detect missing value markers (empty strings and the value of na_values). In
233-
data without any NAs, passing na_filter=False can improve the performance
234-
of reading a large file.
233+
data without any NAs, passing ``na_filter=False`` can improve the
234+
performance of reading a large file.
235235
verbose : bool, default False
236236
Indicate number of NA values placed in non-numeric columns.
237237
parse_dates : bool, list-like, or dict, default False
238238
The behavior is as follows:
239239
240-
* bool. If True -> try parsing the index.
241-
* list of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3
240+
* ``bool``. If True -> try parsing the index.
241+
* ``list`` of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3
242242
each as a separate date column.
243-
* list of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as
243+
* ``list`` of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as
244244
a single date column.
245-
* dict, e.g. {{'foo' : [1, 3]}} -> parse columns 1, 3 as date and call
245+
* ``dict``, e.g. {{'foo' : [1, 3]}} -> parse columns 1, 3 as date and call
246246
result 'foo'
247247
248248
If a column or index contains an unparsable date, the entire column or
@@ -372,7 +372,8 @@
372372
1 NaN 2
373373
2 #Comment 3
374374
375-
Comment lines in the excel input file can be skipped using the `comment` kwarg
375+
Comment lines in the excel input file can be skipped using the
376+
``comment`` kwarg.
376377
377378
>>> pd.read_excel('tmp.xlsx', index_col=0, comment='#') # doctest: +SKIP
378379
Name Value

0 commit comments

Comments
 (0)