-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fix Categorical use_inf_as_na bug #33629
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 all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8985831
BUG: Fix use_inf_as_na bugs
dsaxton 55ed2cf
Note
dsaxton 9582927
Issue number
dsaxton 365df7e
Oops
dsaxton 1d05145
Different check
dsaxton a1b12ba
Merge remote-tracking branch 'upstream/master' into use-inf-as-na
dsaxton c7c03b8
Remove StringArray stuff
dsaxton dbf9830
Fix
dsaxton 60c7625
Update
dsaxton 6b413b4
Merge remote-tracking branch 'upstream/master' into use-inf-as-na
dsaxton ddff3d2
Use equality instead
dsaxton cbfdd6a
Delete _isna_ndarraylike_old
dsaxton 81c310f
Merge remote-tracking branch 'upstream/master' into use-inf-as-na
dsaxton 1838a33
Add some tests
dsaxton 11d50a9
Fix test
dsaxton afa9448
Add docstring
dsaxton c7b65d5
Merge remote-tracking branch 'upstream/master' into use-inf-as-na
dsaxton a95f38c
Fix
dsaxton fe1648f
Nit
dsaxton 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
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.
Should we also test this with putting the Categorical creation outside of the option context?
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.
It turns out that actually fails interestingly enough: #33629 (comment) (if you set the option after constructing the object it loses its effect). What's even more strange is the value displays as NaN:
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.
I think that is somewhat "expected", given the discussion above in #33629 (comment) (not that I like that behaviour though).
But regardless of how the categorical is created (with or without the option), I find it very strange that
isna
is then failingThere 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.
Hmm, being a bit confused in the comment above :)
The Categorical.isna is failing, of course, since it just looks at -1 in the codes, and when inf is part of the categories, it is not -1 in the codes. Hence it is failing to detect it.
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.
@dsaxton so could you additionally test it for
pd.isna
? In constract to Categorical.isna(), pd.isna should work even if the Categorical is created before the context, I think?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.
@jorisvandenbossche Added some tests, let me know if this is roughly what you had in mind
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.
Yes, that looks good!