From f0859429c597369bfe719338f3b9007577fb6d08 Mon Sep 17 00:00:00 2001 From: iridiium <60609879+iridiium@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:08:15 +0000 Subject: [PATCH 1/2] DOC: Fix PR01 and SA01 errors in pandas.ExcelFile --- ci/code_checks.sh | 2 -- pandas/io/excel/_base.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 998e48d96d6b3..1fcaabff89023 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -421,7 +421,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.DatetimeIndex.indexer_at_time\ pandas.DatetimeIndex.snap\ pandas.DatetimeIndex.std\ - pandas.ExcelFile\ pandas.ExcelFile.parse\ pandas.HDFStore.append\ pandas.HDFStore.put\ @@ -966,7 +965,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.DatetimeTZDtype\ pandas.DatetimeTZDtype.tz\ pandas.DatetimeTZDtype.unit\ - pandas.ExcelFile\ pandas.ExcelFile.parse\ pandas.ExcelWriter\ pandas.Flags\ diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index 8a287beac7afd..9ede96c2c7694 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -278,8 +278,17 @@ comment string and the end of the current line is ignored. skipfooter : int, default 0 Rows at the end to skip (0-indexed). -{storage_options} - +storage_options : dict, optional + Extra options that make sense for a particular storage connection, + e.g. host, port, username, password, etc. + + For HTTP(S) URLs the key-value pairs are forwarded to ``urllib.request.Request`` as header options. + For other URLs (e.g. starting with “s3://”, and “gcs://”), + the key-value pairs are forwarded to ``fsspec.open``. + + Please see ``fsspec`` and ``urllib`` for more details, + and for more examples on storage options, + refer `here `. dtype_backend : {{'numpy_nullable', 'pyarrow'}}, default 'numpy_nullable' Back-end data type applied to the resultant :class:`DataFrame` (still experimental). Behaviour is as follows: @@ -1483,6 +1492,15 @@ class ExcelFile: Please do not report issues when using ``xlrd`` to read ``.xlsx`` files. This is not supported, switch to using ``openpyxl`` instead. + storage_options : dict, optional + Extra options that make sense for a particular storage connection, + e.g. host, port, username, password, etc. + + For HTTP(S) URLs the key-value pairs are forwarded to ``urllib.request.Request`` as header options. + For other URLs (e.g. starting with “s3://”, and “gcs://”) the key-value pairs are forwarded to ``fsspec.open``. + + Please see ``fsspec`` and ``urllib`` for more details, + and for more examples on storage options refer `here `. engine_kwargs : dict, optional Arbitrary keyword arguments passed to excel engine. @@ -1491,6 +1509,14 @@ class ExcelFile: >>> file = pd.ExcelFile("myfile.xlsx") # doctest: +SKIP >>> with pd.ExcelFile("myfile.xls") as xls: # doctest: +SKIP ... df1 = pd.read_excel(xls, "Sheet1") # doctest: +SKIP + + See Also + -------- + DataFrame.to_excel : Write DataFrame to an Excel file. + DataFrame.to_csv : Write DataFrame to a comma-separated values (csv) file. + read_csv : Read a comma-separated values (csv) file into DataFrame. + read_fwf : Read a table of fixed-width formatted lines into DataFrame. + """ from pandas.io.excel._calamine import CalamineReader From 0ca1e302c957bf05166ac0cf21040594aa9f3fcc Mon Sep 17 00:00:00 2001 From: iridiium <60609879+iridiium@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:38:57 +0000 Subject: [PATCH 2/2] DOC: Fix formatting of docstring of pandas.ExcelFile --- pandas/io/excel/_base.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index 9ede96c2c7694..3405be626b5f3 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -1503,22 +1503,20 @@ class ExcelFile: and for more examples on storage options refer `here `. engine_kwargs : dict, optional Arbitrary keyword arguments passed to excel engine. - - Examples - -------- - >>> file = pd.ExcelFile("myfile.xlsx") # doctest: +SKIP - >>> with pd.ExcelFile("myfile.xls") as xls: # doctest: +SKIP - ... df1 = pd.read_excel(xls, "Sheet1") # doctest: +SKIP - + See Also -------- DataFrame.to_excel : Write DataFrame to an Excel file. DataFrame.to_csv : Write DataFrame to a comma-separated values (csv) file. read_csv : Read a comma-separated values (csv) file into DataFrame. read_fwf : Read a table of fixed-width formatted lines into DataFrame. - - """ + Examples + -------- + >>> file = pd.ExcelFile("myfile.xlsx") # doctest: +SKIP + >>> with pd.ExcelFile("myfile.xls") as xls: # doctest: +SKIP + ... df1 = pd.read_excel(xls, "Sheet1") # doctest: +SKIP + """ from pandas.io.excel._calamine import CalamineReader from pandas.io.excel._odfreader import ODFReader from pandas.io.excel._openpyxl import OpenpyxlReader