-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: consistency between logical ops & type casts #8151
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
Conversation
@@ -3418,7 +3444,7 @@ def test_comparison_label_based(self): | |||
|
|||
# identity | |||
# we would like s[s|e] == s to hold for any e, whether empty or not | |||
for e in [Series([]),Series([1],['z']),Series(['z']),Series(np.nan,b.index),Series(np.nan,a.index)]: | |||
for e in [Series([]),Series([1],['z']),Series(['z']),Series(False,b.index),Series(False,a.index)]: |
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.
this is a valid test
don't change it
you can add to tests but not change w/o a really good reason
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.
@jreback in python
>>> bool(np.nan)
True
in pandas:
>>> pd.Series([np.nan], dtype='bool')
0 True
dtype: bool
this test passes only if np.nan
is casted to False
.
same comment for the other test.
need a release note |
8fda909
to
27c158b
Compare
27c158b
to
5229ac6
Compare
@behzadnouri can you rebase this. I believe there was another pr with modified this code. |
this pr is based on the assumption that the element-wise logical operations are bound to return a series with i feel like following python's mechanism of boolean operations is a better path. |
can u provide an example of what you think is wrong / what needs changing? |
I mean element-wise and/or etc should actually do element-wise logical operations, so then
for example:
#9338 is sort of doing this for integers, but same can be done for all types as in python |
@behzadnouri we ought to reexamine this for 0.17.0. pls rebase when you have a chance. |
@jreback I close this one per my comment earlier that i no longer feel this is a good approach. I will do a new pr when i get a chance and if i could make it work. |
great thanks! |
Closes #6528.
Currently series logical operations are bound to return a series with
dtype='bool'
. That being a good decision or not, it is good to have some internal consistency:With this patch, all these tests pass.