-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: nullable Float32/64 ExtensionArray #34307
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
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
cddc939
ENH: nullable Float32/64 ExtensionArray
jorisvandenbossche 6a1d822
fix doctest
jorisvandenbossche f43f021
add basic whatsnew note
jorisvandenbossche ffdd65c
typo
jorisvandenbossche 3d189f9
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche ff3b937
fix astype to string
jorisvandenbossche 13b8281
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche 4c1d06c
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche ebbc64d
clean-up arithmetic tests to align with integer/boolean tests
jorisvandenbossche 94be5f2
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche 8cf0d47
updates for feedback
jorisvandenbossche f7cc1be
fix string array construction
jorisvandenbossche 107b083
fix mypy
jorisvandenbossche ba1e62c
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche 879d3e0
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche ed9a14b
rename _FloatingDtype -> FloatingDtype
jorisvandenbossche c16ca4c
update astype implementation to follow IntegerArray changes
jorisvandenbossche aa45aac
clean-up tests
jorisvandenbossche 25eb1ba
remove usage of deprecated check_less_precise
jorisvandenbossche b78c041
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche 45b98f2
fixup merge + skip astype(string) for float32
jorisvandenbossche 314b6a9
linting
jorisvandenbossche a157806
add back type ignore
jorisvandenbossche 81456f9
whatsnew 1.2
jorisvandenbossche 71009c3
update whatsnew
jorisvandenbossche 56d2311
add fixture
jorisvandenbossche 65a2060
share some dtype properties
jorisvandenbossche 8b36098
update ensure_float
jorisvandenbossche 7f3e965
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche 66d6939
remove skip for float32 conversion to string
jorisvandenbossche e0c9d9a
Merge remote-tracking branch 'upstream/master' into EA-floating
jorisvandenbossche d37b815
code formatting
jorisvandenbossche 44e699a
Update doc/source/whatsnew/v1.2.0.rst
jorisvandenbossche b42b61d
Update pandas/core/arrays/floating.py
jorisvandenbossche edf9618
ignore mypy bug
jorisvandenbossche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,6 +109,54 @@ Beginning with this version, the default is now to use the more accurate parser | |
``floating_precision="legacy"`` to use the legacy parser. The change to using the higher precision | ||
parser by default should have no impact on performance. (:issue:`17154`) | ||
|
||
.. _whatsnew_110.floating: | ||
|
||
Experimental nullable data types for float data | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
We've added :class:`Float32Dtype` / :class:`Float64Dtype` and :class:`~arrays.FloatingArray`, | ||
an extension data type dedicated to floating point data that can hold the | ||
``pd.NA`` missing value indicator (:issue:`32265`, :issue:`34307`). | ||
|
||
While the default float data type already supports missing values using ``np.nan``, | ||
this new data type uses ``pd.NA`` (and its corresponding behaviour) as missing | ||
value indicator, in line with the already existing nullable :ref:`integer <integer_na>` | ||
and :ref:`boolean <boolean>` data types. | ||
|
||
One example where the behaviour of ``np.nan`` and ``pd.NA`` is different is | ||
comparison operations: | ||
|
||
.. ipython:: python | ||
|
||
# the default numpy float64 dtype | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could be non-comments (e.g. just before the block itself) |
||
s1 = pd.Series([1.5, None]) | ||
s1 | ||
s1 > 1 | ||
|
||
.. ipython:: python | ||
|
||
# the new nullable float64 dtype | ||
s2 = pd.Series([1.5, None], dtype="Float64") | ||
s2 | ||
s2 > 1 | ||
|
||
See the :ref:`missing_data.NA` doc section for more details on the behaviour | ||
when using the ``pd.NA`` missing value indicator. | ||
|
||
As shown above, the dtype can be specified using the "Float64" or "Float32" | ||
string (capitalized to distinguish it from the default "float64" data type). | ||
Alternatively, you can also use the dtype object: | ||
|
||
.. ipython:: python | ||
|
||
pd.Series([1.5, None], dtype=pd.Float32Dtype()) | ||
|
||
.. warning:: | ||
|
||
Experimental: the new floating data types are currently experimental, and its | ||
behaviour or API may still change without warning. Expecially the behaviour | ||
regarding NaN (distinct from NA missing values) is subject to change. | ||
|
||
.. _whatsnew_120.enhancements.other: | ||
|
||
Other enhancements | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.