Skip to content

CLN: simplify Categorical comparisons #36237

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 1 commit into from
Sep 11, 2020

Conversation

jbrockmendel
Copy link
Member

Not as much as I had hoped, but not nothing.

Comment on lines 102 to +104
mask = (self._codes == -1) | (other_codes == -1)
if mask.any():
# In other series, the leads to False, so do that here too
if opname == "__ne__":
ret[(self._codes == -1) & (other_codes == -1)] = True
else:
ret[mask] = False
ret[mask] = fill_value
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to simplify further to only ret[(self._codes == -1) | (other_codes == -1)] = fill_value (or remove the if mask.any())?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm OK with it either way; we use the if mask.any() check elsewhere

@jreback jreback added Categorical Categorical Data Type Clean labels Sep 9, 2020
@jreback jreback added this to the 1.2 milestone Sep 9, 2020
@jreback jreback merged commit 49b342b into pandas-dev:master Sep 11, 2020
@jbrockmendel jbrockmendel deleted the ref-cat-cmp-2 branch September 11, 2020 14:34
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Clean
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants