-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: PeriodIndex fails to handle NA, rather than putting NaT in its place (#46673) #47780
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 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3b589b1
BUG: PeriodIndex fails to handle NA, rather than putting NaT in its p…
kapiliyer 8ba96f2
BUG: PeriodIndex fails to handle NA, rather than putting NaT in its p…
kapiliyer 9ff4708
Merge branch 'main' into bug_46673
kapiliyer f2c6723
BUG: Series.astype is unable to handle pd.nan.
kapiliyer 3d9e157
BUG: PeriodIndex fails to handle NA, rather than putting NaT in its p…
kapiliyer c28fd8a
Merge branch 'main' into bug_46673
kapiliyer ab1d2a7
BUG: Series.astype is unable to handle pd.nan (#46377)
kapiliyer ca6c0fd
BUG: PeriodIndex fails to handle NA, rather than putting NaT in its p…
kapiliyer 8e53d06
BUG: PeriodIndex fails to handle NA, rather than putting NaT in its p…
kapiliyer caa4a83
Merge branch 'main' into bug_46673
kapiliyer 3458d3d
BUG: PeriodIndex fails to handle NA, rather than putting NaT in its p…
kapiliyer 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -446,7 +446,7 @@ def test_astype_string_to_extension_dtype_roundtrip( | |
self, data, dtype, request, nullable_string_dtype | ||
): | ||
if dtype == "boolean" or ( | ||
dtype in ("period[M]", "datetime64[ns]", "timedelta64[ns]") and NaT in data | ||
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. Partially addresses #40566 by fixing handling of pd.NA for conversion to period types. |
||
dtype in ("datetime64[ns]", "timedelta64[ns]") and NaT in data | ||
): | ||
mark = pytest.mark.xfail( | ||
reason="TODO StringArray.astype() with missing values #GH40566" | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbrockmendel I guess NaT is NA-like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depends on context. NA has different semantics than NaN/NaT, so it isn't obvious we should accept it everywhere.
changing it here in particular changes behavior in a bunch of places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbrockmendel
Thank you for the input. I see how this function is used in a lot of different places, not just in converting to PeriodIndex which is the main thing I was trying to get at. I will try an approach that more directly tackles the specific case of #46673 (assuming that the expected behavior listed in the issue is valid, i.e.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it isn't entirely obvious that this should be the expected behavior. bc pd.NA has different semantics than pd.NaT, we might want to distinguish between them in this context and do some kind of NullableArray[Period]
This also would introduce an inconsistency between PeriodIndex vs the Period constructor, which is a whole other can of worms (and then we get to the same issues for Timestamp/Timedelta...)
Then again, I'm an outlier in crankiness on pd.NA-consistency-headaches, so if @mroeschke is fine with the proposed behavior, i won't make a stink about it.