-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Series.any() and .all() don't return bool values if dtype=object #12863
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
Comments
what you are doing doesn't make any sense but it is correct. http://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.any.html I guess this should return a boolean. But to be honest I don't know what numpy is doing.
|
Hmm..., yes, it is correct
I suppose we could call
|
yep, looks like this is the case for
|
ok, I think we will add a @jdavies1618 want to do a pull-request? |
Will do - thanks for the quick feedback! |
This is weird, it looks like there are some discrepancies in the test suite for nanall and nanany.
In my opinion, it would be relevant (and more coherent) to have the same behavior as python any and all buitlin methods, such that: If this is the case, I have a commit that fixes it, but I then would have to change the test suite also. |
so what are you proposing for changes? |
Here's a pass I took: --- a/pandas/tests/series/test_analytics.py
|
There are more complete tests to be done for proper coverage of all possible situation. |
Sorry, I was too fast, there are still errors in tests, sorry |
Notice this is considered a bug and is (or was) worked on in numpy: So that's probably where effort would better be directed. |
good luck with that. And even if a PR was actually proposed / accepted, then this bug would linger in pandas even longer. Much better to do a fix here. |
For 'any()' and 'all()' not returning bool when ndarray is an object
take |
For 'any()' and 'all()' not returning bool when ndarray is an object
For 'any()' and 'all()' not returning bool when ndarray is an object
For 'any()' and 'all()' not returning bool when ndarray is an object
For 'any()' and 'all()' not returning bool when ndarray is an object
For 'any()' and 'all()' not returning bool when ndarray is an object
For the current state of the code, this change is not required. It will, however, save someone fixing this in future, when actually wanting to use a newer OpenSAFELY Python image. However, the tests currently rely on a quirky behaviour of `.all()` in pandas that has been fixed. In the version of pandas inside the `python:latest` image (v1.0.1), the behaviour is that `.all()` can return an `dtype=object` instead of a Boolean, and our tests as written pass. In later versions of pandas, `.all()` returns a Boolean instead, and our tests fail. We can rewrite the tests to work both prior to and post this pandas fix. This was checked by running the tests with the `Dockerfile` as provided, and editing the `Dockerfile` to use the `v2` OpenSAFELY Python image. See pandas-dev/pandas#12863.
Code Sample, a copy-pastable example if possible
Expected Output
[True, True]
Actual output
['a', 'e']
output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: