10000 ENH: Allow safe access to `.book` in ExcelWriter by rhshadrach · Pull Request #45687 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ENH: Allow safe access to .book in ExcelWriter #45687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
docstrings
  • Loading branch information
rhshadrach committed Jan 31, 2022
commit d8415bfa4f32d570590a8595cbad8df98dde2f24
2 changes: 1 addition & 1 deletion pandas/io/excel/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ def engine(self) -> str:
@property
@abc.abstractmethod
def sheets(self) -> dict[str, Any]:
"""Mapping of sheet name to sheet object."""
"""Mapping of sheet names to sheet objects."""
pass

@abc.abstractmethod
Expand Down
1 change: 1 addition & 0 deletions pandas/io/excel/_odswriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(

@property
def sheets(self) -> dict[str, Any]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to type these more specifically?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not easily, as far as I can tell. I plan to look into this more in the future.

Regarding whatsnew - this is not user facing. Currently in docs no attribute of ExcelWriter is public. I'd like to refactor ExcelWriter (namely, making protected attributes start with _) before updating docs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it totally fine (make issues if you cannot to get to it soon), otherwise PR's totally fine.

is there a way to type these more specifically?

can we use the base class generic for typing? (again nbd)

"""Mapping of sheet names to sheet objects."""
from odf.table import Table

result = {
Expand Down
1 change: 1 addition & 0 deletions pandas/io/excel/_openpyxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(

@property
def sheets(self) -> dict[str, Any]:
"""Mapping of sheet names to sheet objects."""
result = {name: self.book[name] for name in self.book.sheetnames}
return result

Expand Down
1 change: 1 addition & 0 deletions pandas/io/excel/_xlwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(

@property
def sheets(self) -> dict[str, Any]:
"""Mapping of sheet names to sheet objects."""
result = {sheet.name: sheet for sheet in self.book._Workbook__worksheets}
return result

Expand Down
0