Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
import pandas as pd, numpy as np
print(pd.__version__)
print(np.__version__)
# 1.2.2
# 1.19.5
conditions = pd.Index([True, True, True, True, True, True], dtype='object')
conditions
# Index([True, True, True, True, True, True], dtype='object')
np.all(conditions.values)
# True
np.all(conditions)
# ---------------------------------------------------------------------------
# TypeError Traceback (most recent call last)
# <ipython-input-102-9a6b94382bda> in <module>
# ----> 1 np.all(conditions)
# <__array_function__ internals> in all(*args, **kwargs)
# ~/anaconda3/envs/soothsayer5_env/lib/python3.8/site-packages/numpy/core/fromnumeric.py in all(a, axis, out, keepdims)
# 2409
# 2410 """
# -> 2411 return _wrapreduction(a, np.logical_and, 'all', axis, None, out, keepdims=keepdims)
# 2412
# 2413
# ~/anaconda3/envs/soothsayer5_env/lib/python3.8/site-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
# 83 return reduction(axis=axis, dtype=dtype, out=out, **passkwargs)
# 84 else:
# ---> 85 return reduction(axis=axis, out=out, **passkwargs)
# 86
# 87 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
# TypeError: all() got an unexpected keyword argument 'axis'
Problem description
[this should explain why the current behaviour is a problem and why the expected output is a better solution]
For years I've been using pandas index arrays with only True/False entries. np.all
was always able to handle these and for some reason it cannot anymore. I'm not sure why and the error message is not intuitive to me since I'm not using an axis keyword.
Expected Output
True or False
Output of pd.show_versions()
[paste the output of pd.show_versions()
here leaving a blank line after the details tag]
INSTALLED VERSIONS
commit : 7d32926
python : 3.8.5.final.0
python-bits : 64
OS : Darwin
OS-release : 19.5.0
Version : Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.2
numpy : 1.19.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.2
setuptools : 49.3.1.post20200810
Cython : 0.29.21
pytest : 6.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : 4.5.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.17.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fsspec : 0.8.0
fastparquet : 0.4.0
gcsfs : None
matplotlib : 3.3.1
numexpr : None
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : 1.0.1
pyxlsb : None
s3fs : None
scipy : 1.5.2
sqlalchemy : 1.3.16
tables : None
tabulate : None
xarray : 0.16.2
xlrd : 1.2.0
xlwt : None
numba : 0.50.1