You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
IIUC for pandas extension arrays, for each location where _mask is True, the value of _data should be irrelevant. However this is not the case for __array_ufunc__:
In [1]: importpandasaspd
...: importnumpyasnp
...:
...: arr=pd.array([True, False, pd.NA], dtype="boolean")
...: arrOut[1]:
<BooleanArray>
[True, False, <NA>]
Length: 3, dtype: booleanIn [2]: y=np.ones(3, bool)
...: out=np.ones(3, bool)
...:
...: np.logical_and(arr, y, out=out)
...: outOut[2]: array([ True, False, False])
In [3]: arr._data[2] =True# This does not change arr since arr._mask[2] = True
...:
...: np.logical_and(arr, y, out=out)
...: outOut[3]: array([ True, False, True])
Another important aspect is that we currently return an object-typed numpy array if we we don't specify out but rather let it return an ExtensionArray and then convert to numpy:
As it is hard to tell which boolean value should be used for missings, I would raise an error in the case that you have inputs with missings but the out-dtype doesn't support it.
mroeschke
added
Compat
pandas objects compatability with Numpy or Python functions
and removed
Needs Triage
Issue that has not been reviewed by a pandas team member
labels
Aug 21, 2021
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.
IIUC for pandas extension arrays, for each location where
_mask
isTrue
, the value of_data
should be irrelevant. However this is not the case for__array_ufunc__
:Relevant code:
pandas/pandas/core/arrays/boolean.py
Lines 366 to 390 in 17ecb56
Here we are calling
which adjusts
out
in-place, ignoring the mask and depending onarr._data[2]
.This issue shows how this might be an issue:
numpy/numpy#19374
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2cb9652
python : 3.9.2.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-74-generic
Version : #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.4
numpy : 1.21.0
pytz : 2021.1
dateutil : 2.8.1
pip : 21.1.1
setuptools : 49.6.0.post20210108
Cython : None
pytest : 6.2.3
hypothesis : None
sphinx : 3.5.4
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.23.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : 2021.04.0
fastparquet : None
gcsfs : None
matplotlib : 3.4.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 4.0.1
pyxlsb : None
s3fs : None
scipy : 1.6.3
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: