Skip to content

Commit 873a86b

Browse files
committed
DOC: inline docstrings for read_excel with additional formatting.
1 parent 40bf0e9 commit 873a86b

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

pandas/io/excel/_base.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def read_excel(
227227
* ``1``: 2nd sheet as a `DataFrame`
228228
* ``"Sheet1"``: Load sheet with name "Sheet1"
229229
* ``[0, 1, "Sheet5"]``: Load first, second and sheet named "Sheet5"
230-
as a dict of `DataFrame`
230+
as a dict of `DataFrame`
231231
* ``None``: All worksheets.
232232
233233
header : int, list of int, default 0
@@ -239,23 +239,25 @@ def read_excel(
239239
then you should explicitly pass header=None.
240240
index_col : int, str, list of int, default None
241241
Column (0-indexed) to use as the row labels of the DataFrame.
242-
Pass None if there is no such column. If a list is passed,
243-
those columns will be combined into a ``MultiIndex``. If a
242+
Pass None if there is no such column. If a list is passed,
243+
those columns will be combined into a ``MultiIndex``. If a
244244
subset of data is selected with ``usecols``, index_col
245245
is based on the subset.
246+
246247
Missing values will be forward filled to allow roundtripping with ``to_excel``
247248
for ``merged_cells=True``. To avoid forward filling the missing values use
248249
``set_index`` after reading the data instead of ``index_col``.
250+
249251
usecols : str, list-like, or callable, default None
250252
* If None, then parse all columns.
251253
* If str, then indicates comma separated list of Excel column letters
252-
and column ranges (e.g. "A:E" or "A,C,E:F"). Ranges are inclusive of
253-
both sides.
254+
and column ranges (e.g. "A:E" or "A,C,E:F"). Ranges are inclusive of
255+
both sides.
254256
* If list of int, then indicates list of column numbers to be parsed
255-
(0-indexed).
257+
(0-indexed).
256258
* If list of string, then indicates list of column names to be parsed.
257259
* If callable, then evaluate each column name against it and parse the
258-
column if the callable returns ``True``.
260+
column if the callable returns ``True``.
259261
260262
Returns a subset of the columns according to behavior above.
261263
@@ -272,15 +274,15 @@ def read_excel(
272274
273275
- ``openpyxl`` supports newer Excel file formats.
274276
- ``calamine`` supports Excel (.xls, .xlsx, .xlsm, .xlsb)
275-
and OpenDocument (.ods) file formats.
277+
and OpenDocument (.ods) file formats.
276278
- ``odf`` supports OpenDocument file formats (.odf, .ods, .odt).
277279
- ``pyxlsb`` supports Binary Excel files.
278280
- ``xlrd`` supports old-style Excel files (.xls).
279281
280282
When ``engine=None``, the following logic will be used to determine the engine:
281283
282284
- If ``path_or_buffer`` is an OpenDocument format (.odf, .ods, .odt),
283-
then `odf <https://pypi.org/project/odfpy/>`_ will be used.
285+
then `odf <https://pypi.org/project/odfpy/>`_ will be used.
284286
- Otherwise if ``path_or_buffer`` is an xls format, ``xlrd`` will be used.
285287
- Otherwise if ``path_or_buffer`` is in xlsb format, ``pyxlsb`` will be used.
286288
- Otherwise ``openpyxl`` will be used.
@@ -313,13 +315,13 @@ def read_excel(
313315
Depending on whether ``na_values`` is passed in, the behavior is as follows:
314316
315317
* If ``keep_default_na`` is True, and ``na_values`` are specified,
316-
``na_values`` is appended to the default NaN values used for parsing.
318+
``na_values`` is appended to the default NaN values used for parsing.
317319
* If ``keep_default_na`` is True, and ``na_values`` are not specified, only
318-
the default NaN values are used for parsing.
320+
the default NaN values are used for parsing.
319321
* If ``keep_default_na`` is False, and ``na_values`` are specified, only
320-
the NaN values specified ``na_values`` are used for parsing.
322+
the NaN values specified ``na_values`` are used for parsing.
321323
* If ``keep_default_na`` is False, and ``na_values`` are not specified, no
322-
strings will be parsed as NaN.
324+
strings will be parsed as NaN.
323325
324326
Note that if `na_filter` is passed in as False, the ``keep_default_na`` and
325327
``na_values`` parameters will be ignored.
@@ -328,21 +330,23 @@ def read_excel(
328330
Detect missing value markers (empty strings and the value of na_values). In
329331
data without any NAs, passing ``na_filter=False`` can improve the performance
330332
of reading a large file.
333+
331334
verbose : bool, default False
332335
Indicate number of NA values placed in non-numeric columns.
336+
333337
parse_dates : bool, list-like, or dict, default False
334338
The behavior is as follows:
335339
336340
* ``bool``. If True -> try parsing the index.
337341
* ``list`` of int or names. e.g. If [1, 2, 3] -> try parsing columns 1, 2, 3
338-
each as a separate date column.
342+
each as a separate date column.
339343
* ``list`` of lists. e.g. If [[1, 3]] -> combine columns 1 and 3 and parse as
340-
a single date column.
344+
a single date column.
341345
* ``dict``, e.g. {'foo' : [1, 3]} -> parse columns 1, 3 as date and call
342-
result 'foo'
346+
result 'foo'
343347
344348
If a column or index contains an unparsable date, the entire column or
345-
index will be returned unaltered as an object data type. If you don`t want to
349+
index will be returned unaltered as an object data type. If you dont want to
346350
parse some cells as date just change their type in Excel to "Text".
347351
For non-standard datetime parsing, use ``pd.to_datetime`` after
348352
``pd.read_excel``.

0 commit comments

Comments
 (0)