-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
Bitwise operation weirdness #9016
Comments
can you show a full copy/pastable example, and These are the bitwise operators......(and integers will get coerced) |
Here:
Seems like |
numpy does this (and that's what Series is doing)
Why are you doing this? These are boolean comparison ops, not bitwise-ops |
Sorry, I edited the post while you were viewing. With
We weren't actually trying to do this, but we had an errant type conversion somewhere else that cause strange behavior due to weak-typing in Pandas, and I found this while investigating what other strange behaviors might result. |
I can reproduce this on master. I agree that we should probably stick to what numpy does and not coerce to booleans. I'm not sure I'd call this a bug exactly, but it does seem like an undesirable inconsistency. |
Tried a quick & dirty hack and getting back desired behavior. Tests passed too. Sharing snippet so I can gather some expert comments and advise. Would be happy to work on a pull request if this looks in the correct direction. Thanks.
Some outputs showing results after the above fix
Thanks, |
this should be handled in |
@jreback thanks. I will look into this and try and work on a PR. |
@jreback for now, I have made the changes in wrapper() itself instead of na_op() because it looked to me like wrapper is controlling the input and output fill and dtype. Once wrapper() takes care of this, na_op() seems to be doing the right thing by itself and so I did not have to change anything to get back the expected behavior. Happy to change if things need to be altered toward better design etc. Thanks. |
closed by #9338 |
It seems like
pd.Series([x]) | pd.Series([y])
withx, y
integers returnspd.Series([x | y]).astype(bool)
. This is a reasonable semantic, butpd.Series([x]) & pd.Series([y])
seems to returnpd.Series([x & y % 2]) == 1
, which is a lot weirder. Is there a justification for this? I couldn't find one in the documentation (&
is hard to search!), so it may be a bug.The text was updated successfully, but these errors were encountered: