Skip to content

ENH: Add use nullable dtypes to read_excel #49091

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
Oct 25, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Oct 14, 2022

This sits on top of #49089.

Would prefer round tripping during testing instead of adding those files to the repository

@phofl phofl added Enhancement IO Excel read_excel, to_excel NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Oct 14, 2022
phofl added 2 commits October 14, 2022 16:10
# Conflicts:
#	doc/source/whatsnew/v2.0.0.rst
#	pandas/io/excel/_base.py
#	pandas/tests/io/excel/test_readers.py
#	pandas/tests/io/excel/test_writers.py
@phofl
Copy link
Member Author

phofl commented Oct 23, 2022

This is ready now

@@ -271,6 +271,13 @@

.. versionadded:: 1.2.0

use_nullable_dtypes : bool = False
Copy link
Member

Choose a reason for hiding this comment

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

: bool, default False here I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

with tm.ensure_clean(read_ext) as file_path:
df.to_excel(file_path, "test", index=False)
result = pd.read_excel(
file_path, sheet_name="test", use_nullable_dtypes=True, dtype="float64"
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense to me that dtype overrides use_nullable_dtypes - could you add this to the docstring.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@rhshadrach rhshadrach added this to the 2.0 milestone Oct 25, 2022
Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

lgtm

@rhshadrach rhshadrach merged commit 22e591f into pandas-dev:main Oct 25, 2022
@rhshadrach
Copy link
Member

Thanks @phofl

@phofl phofl deleted the use_nullable_in_excel branch October 25, 2022 14:10
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement IO Excel read_excel, to_excel NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: add option to get nullable dtypes to pd.read_csv
2 participants