Skip to content

Commit 5ddcd06

Browse files
committed
DOC: inline docstrings for read_excel and storage options in io/excel/base.py. with Ruff formatting fixes
1 parent f6bdf93 commit 5ddcd06

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

pandas/io/excel/_base.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from decimal import Decimal
1212
from functools import partial
1313
import os
14-
from textwrap import fill
1514
from typing import (
1615
IO,
1716
TYPE_CHECKING,
@@ -30,13 +29,12 @@
3029
from pandas._config import config
3130

3231
from pandas._libs import lib
33-
from pandas._libs.parsers import STR_NA_VALUES
3432
from pandas.compat._optional import (
3533
get_version,
3634
import_optional_dependency,
3735
)
3836
from pandas.errors import EmptyDataError
39-
from pandas.util._decorators import (set_module)
37+
from pandas.util._decorators import set_module
4038
from pandas.util._exceptions import find_stack_level
4139
from pandas.util._validators import check_dtype_backend
4240

@@ -50,7 +48,6 @@
5048
)
5149

5250
from pandas.core.frame import DataFrame
53-
from pandas.core.shared_docs import _shared_docs
5451
from pandas.util.version import Version
5552

5653
from pandas.io.common import (
@@ -254,13 +251,13 @@ def read_excel(
254251
usecols : str, list-like, or callable, default None
255252
* If None, then parse all columns.
256253
* If str, then indicates comma separated list of Excel column letters
257-
and column ranges (e.g. "A:E" or "A,C,E:F"). Ranges are inclusive of
258-
both sides.
254+
and column ranges (e.g. "A:E" or "A,C,E:F"). Ranges are inclusive of
255+
both sides.
259256
* If list of int, then indicates list of column numbers to be parsed
260257
(0-indexed).
261258
* If list of string, then indicates list of column names to be parsed.
262259
* If callable, then evaluate each column name against it and parse the
263-
column if the callable returns ``True``.
260+
column if the callable returns ``True``.
264261
265262
Returns a subset of the columns according to behavior above.
266263
dtype : Type name or dict of column -> type, default None
@@ -318,11 +315,11 @@ def read_excel(
318315
* If ``keep_default_na`` is True, and ``na_values`` are specified,
319316
``na_values`` is appended to the default NaN values used for parsing.
320317
* If ``keep_default_na`` is True, and ``na_values`` are not specified, only
321-
the default NaN values are used for parsing.
318+
the default NaN values are used for parsing.
322319
* If ``keep_default_na`` is False, and ``na_values`` are specified, only
323-
the NaN values specified ``na_values`` are used for parsing.
320+
the NaN values specified ``na_values`` are used for parsing.
324321
* If ``keep_default_na`` is False, and ``na_values`` are not specified, no
325-
strings will be parsed as NaN.
322+
strings will be parsed as NaN.
326323
327324
Note that if `na_filter` is passed in as False, the ``keep_default_na`` and
328325
``na_values`` parameters will be ignored.
@@ -436,22 +433,21 @@ def read_excel(
436433
--------
437434
The file can be read using the file name as string or an open file object:
438435
439-
>>> pd.read_excel('tmp.xlsx', index_col=0) # doctest: +SKIP
436+
>>> pd.read_excel("tmp.xlsx", index_col=0) # doctest: +SKIP
440437
Name Value
441438
0 string1 1
442439
1 string2 2
443440
2 #Comment 3
444441
445-
>>> pd.read_excel(open('tmp.xlsx', 'rb'),
446-
... sheet_name='Sheet3') # doctest: +SKIP
442+
>>> pd.read_excel(open("tmp.xlsx", "rb"), sheet_name="Sheet3") # doctest: +SKIP
447443
Unnamed: 0 Name Value
448444
0 0 string1 1
449445
1 1 string2 2
450446
2 2 #Comment 3
451447
452448
Index and header can be specified via the `index_col` and `header` arguments
453449
454-
>>> pd.read_excel('tmp.xlsx', index_col=None, header=None) # doctest: +SKIP
450+
>>> pd.read_excel("tmp.xlsx", index_col=None, header=None) # doctest: +SKIP
455451
0 1 2
456452
0 NaN Name Value
457453
1 0.0 string1 1
@@ -460,8 +456,9 @@ def read_excel(
460456
461457
Column types are inferred but can be explicitly specified
462458
463-
>>> pd.read_excel('tmp.xlsx', index_col=0,
464-
... dtype={'Name': str, 'Value': float}) # doctest: +SKIP
459+
>>> pd.read_excel(
460+
... "tmp.xlsx", index_col=0, dtype={"Name": str, "Value": float}
461+
... ) # doctest: +SKIP
465462
Name Value
466463
0 string1 1.0
467464
1 string2 2.0
@@ -471,8 +468,9 @@ def read_excel(
471468
but can be explicitly specified, too. Supply the values you would like
472469
as strings or lists of strings!
473470
474-
>>> pd.read_excel('tmp.xlsx', index_col=0,
475-
... na_values=['string1', 'string2']) # doctest: +SKIP
471+
>>> pd.read_excel(
472+
... "tmp.xlsx", index_col=0, na_values=["string1", "string2"]
473+
... ) # doctest: +SKIP
476474
Name Value
477475
0 NaN 1
478476
1 NaN 2
@@ -481,7 +479,7 @@ def read_excel(
481479
Comment lines in the excel input file can be skipped using the
482480
``comment`` kwarg.
483481
484-
>>> pd.read_excel('tmp.xlsx', index_col=0, comment='#') # doctest: +SKIP
482+
>>> pd.read_excel("tmp.xlsx", index_col=0, comment="#") # doctest: +SKIP
485483
Name Value
486484
0 string1 1.0
487485
1 string2 2.0

0 commit comments

Comments
 (0)