From 9dd2d6eb191fb599fdc02f1e5c1e3c3b97b08ba6 Mon Sep 17 00:00:00 2001 From: Jordan Murphy <35613487+jordan-d-murphy@users.noreply.github.com> Date: Sun, 10 Mar 2024 19:38:17 -0600 Subject: [PATCH 1/3] Fix GL08 error for pandas.ExcelFile.book --- ci/code_checks.sh | 1 - pandas/io/excel/_base.py | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 8227047839f3d..66708eb88ca87 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -144,7 +144,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (GL08)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL08 --ignore_functions \ - pandas.ExcelFile.book\ pandas.Index.empty\ pandas.Index.names\ pandas.Index.view\ diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index 2977f62b4d3c5..87c2f7d5ae739 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -1631,6 +1631,32 @@ def parse( @property def book(self): + """ + Gets the Excel workbook. + + Workbook is the top-level container for all document information. + + Returns + ------- + Excel Workbook + The workbook object of the type defined by the engine being used. + + See Also + -------- + read_excel : Read an Excel file into a pandas DataFrame. + + Examples + -------- + >>> file = pd.ExcelFile("myfile.xlsx") # doctest: +SKIP + >>> file.book + + >>> file.book.path + '/xl/workbook.xml' + >>> file.book.active + + >>> file.book.sheetnames + ['Sheet1', 'Sheet2'] + """ return self._reader.book @property From 3fd84c4a97dfe024ff2735d74b3a220161c60694 Mon Sep 17 00:00:00 2001 From: Jordan Murphy <35613487+jordan-d-murphy@users.noreply.github.com> Date: Sun, 10 Mar 2024 20:44:12 -0600 Subject: [PATCH 2/3] fixing NameError("name 'file' is not defined") --- pandas/io/excel/_base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index 87c2f7d5ae739..bdd1d99618b2c 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -1647,13 +1647,13 @@ def book(self): Examples -------- - >>> file = pd.ExcelFile("myfile.xlsx") # doctest: +SKIP + >>> file = pd.ExcelFile("MyWorkbook.xlsx") >>> file.book - + >>> file.book.path '/xl/workbook.xml' >>> file.book.active - + >>> file.book.sheetnames ['Sheet1', 'Sheet2'] """ From c3a2259211847c61a6682fbef57520e32c9fa903 Mon Sep 17 00:00:00 2001 From: Jordan Murphy <35613487+jordan-d-murphy@users.noreply.github.com> Date: Sun, 10 Mar 2024 22:07:35 -0600 Subject: [PATCH 3/3] fixing No Such File errors in code example --- pandas/io/excel/_base.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index bdd1d99618b2c..a9da95054b81a 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -1647,14 +1647,14 @@ def book(self): Examples -------- - >>> file = pd.ExcelFile("MyWorkbook.xlsx") - >>> file.book + >>> file = pd.ExcelFile("myfile.xlsx") # doctest: +SKIP + >>> file.book # doctest: +SKIP - >>> file.book.path + >>> file.book.path # doctest: +SKIP '/xl/workbook.xml' - >>> file.book.active + >>> file.book.active # doctest: +SKIP - >>> file.book.sheetnames + >>> file.book.sheetnames # doctest: +SKIP ['Sheet1', 'Sheet2'] """ return self._reader.book