-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
NaN values impact binary or operations asymmetrically #6528
Comments
this could be a bug, but you boolean comparison of See the long and compliacted tests here: if you see a bug, pls submit a PR will mark it as a bug, but come back to us with your thoughts |
@jreback there are 3 issues above:
this is really bad; because outcome of
|
@behzadnouri ok.....pls make a PR to fix! Keep in mind their may be some reasons buried for this; e.g. put in tests for the 'correct' behavior and see what breaks.
|
@hayd pls chime in here when you can....IIRC you and I discussed these types of things at length |
some discussion was here: #4953. A lot of this is as we're fighting "strange" truthiness for numpy's and python's (!) nan, so things like astype we can't/shouldn't fix... kinda a "gotcha". IMO asymmetry is a bug but only because we're forcing a boolean return value (the reason this happens is cos in numpy and in general |
My 2c: I would separate this out to two issues: Issue 1: Any boolean operations should behave the same as if Issue 2: Should At any rate, I view these as two separate (but obviously related) issues, which I think are being slightly conflated in this issue (and #8151). I would suggest first addressing Issue 1, which seems to me clearly to be a bug -- keeping the existing behavior of treating |
as long as the logical operations are bound to return
that would not be achievable. for example,
strongly discourage that, because: -1- it is not only numpy, but as you also mentioned, and much more importantly that is how python works:
so, it can easily break things as simple as -2- the gain of breaking that consistency, if any, is less than minimal. because, if a user wants to deviate from python's convention that is more than easy: |
D'oh! @behzadnouri, of course you're right about Re: |
NaN
values impact binary or operations asymmetrically
Tried to find the most current open issue on this - the others are closed or merged, but this is open even though being milestoned since 0.14? I asked a question about this on stackexchange, and someone took the time to identify the apparent source of the issue (as well as a work-around): https://stackoverflow.com/a/47664356/2965879 The main issue seems that in pandas.core.ops.wrapper (https://github.com/pandas-dev/pandas/blob/master/pandas/core/ops.py#L928), after aligning the series, only |
I don't expect the behavior of |
I am not sure if this is on purpose, but as far as I know,
or
operation should be symmetric ( I meana | b == b | a
); not in pandas:is there any reason pandas is treating
NaN
values asymmetrically in here?also, this is a weird outcome as well:
and this:
this even has internal inconsistency; so before in
b | a
,NaN
was treated asFalse
, but now here it isTrue
;The text was updated successfully, but these errors were encountered: