Make Index.all compatible with numpy.all by pauldmccarthy · Pull Request #40180 · pandas-dev/pandas (original) (raw)

Due to a bug in my own code, I discovered that pandas.Index objects cannot be passed to the numpy.all function:

In [1]: import numpy as np

In [2]: import pandas as pd

In [3]: idx = pd.Int64Index([1,2,3,4,5])

In [4]: np.all(idx)

TypeError Traceback (most recent call last) in ----> 1 np.all(idx)

<__array_function__ internals> in all(*args, **kwargs)

~/venvs/funpack.venv/lib/python3.7/site-packages/numpy/core/fromnumeric.py in all(a, axis, out, keepdims, where) 2437 """ 2438 return _wrapreduction(a, np.logical_and, 'all', axis, None, out, -> 2439 keepdims=keepdims, where=where) 2440 2441

~/venvs/funpack.venv/lib/python3.7/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'