-
-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
ENH: Support logical and/or (bitwise ops) for nullable IntegerArray #34463
Comments
Maybe I'm missing something, but even the output for int64 seems buggy / strange (mostly the third element for each): import pandas as pd
left = pd.Series([0, 1, 2, 3])
right = pd.Series([0, 0, 1, 2])
print(left | right)
# 0 0
# 1 1
# 2 3
# 3 3
# dtype: int64
print(left & right)
# 0 0
# 1 0
# 2 0
# 3 2
# dtype: int64 |
Looks like the strangeness comes from numpy. In any case a separate issue from the error with Int64 arrays I think. >>> import numpy as np
>>> np.array([0, 1, 2, 3]) | np.array([0, 0, 1, 2])
array([0, 1, 3, 3])
>>> np.array([0, 1, 2, 3]) & np.array([0, 0, 1, 2])
array([0, 0, 0, 2]) |
And not even numpy, as python does the same (example for the third elements):
Note that this are bitwise operators.
So given that this is a quite specific operation, I think it was simply not a priority to implement and test for the new nullable integer dtype. |
Ah that makes sense, I was comparing to the built-in "or" |
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: cc6348
Logical and/or (
&
,|
) on integer Series returns an integer Series:Doing this for a nullable IntegerArray, I expect the result to be another IntegerArray, but it raises a TypeError:
Traceback
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : cc63484
python : 3.7.7.final.0
python-bits : 64
OS : Darwin
OS-release : 19.4.0
Version : Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/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.1.0.dev0+1710.gcc634842a
numpy : 1.18.4
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 41.2.0
Cython : 0.29.19
pytest : 5.4.2
hypothesis : 5.16.0
sphinx : 3.0.4
blosc : 1.9.1
feather : None
xlsxwriter : 1.2.8
lxml.etree : 4.5.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.14.0
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fastparquet : 0.4.0
gcsfs : None
matplotlib : 3.2.1
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : 0.17.1
pytables : None
pyxlsb : None
s3fs : 0.4.2
scipy : 1.4.1
sqlalchemy : 1.3.17
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.15.1
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.49.1
The text was updated successfully, but these errors were encountered: