BUG: Inconsistent behavior with bitwise operations on Series with np.array vs. list #51521
Closed
3 tasks done
Labels
Bug
Needs Triage
Issue that has not been reviewed by a pandas team member
Numeric Operations
Arithmetic, Comparison, and Logical operations
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
If you have a
Series
of integers, and you do a bitwise operation using&
,|
or^
("and", "or", or "xor"), where the other argument is a list, you get different results than if the argument is a numpy array.Note in the example above how
s & np.array([1,2,3])
produces aSeries
of integers, whiles & [1,2,3]
produces aSeries
ofbool
Also, note that
numpy
produces an array of integers, not bools.Expected Behavior
The behavior should be consistent whether the operand is a numpy array or a list of integers.
Installed Versions
INSTALLED VERSIONS
commit : 8d2a4e1
python : 3.8.16.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 13, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 2.1.0.dev0+5.g8d2a4e11d1
numpy : 1.23.5
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 66.1.1
pip : 23.0
Cython : 0.29.32
pytest : 7.2.1
hypothesis : 6.68.1
sphinx : 4.5.0
blosc : None
feather : None
xlsxwriter : 3.0.8
lxml.etree : 4.9.2
html5lib : 1.1
pymysql : 1.0.2
psycopg2 : 2.9.3
jinja2 : 3.1.2
IPython : 8.10.0
pandas_datareader: None
bs4 : 4.11.2
bottleneck : 1.3.6
brotli :
fastparquet : 2023.2.0
fsspec : 2023.1.0
gcsfs : 2023.1.0
matplotlib : 3.6.3
numba : 0.56.4
numexpr : 2.8.3
odfpy : None
openpyxl : 3.1.0
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : 1.2.0
pyxlsb : 1.0.10
s3fs : 2023.1.0
scipy : 1.10.0
snappy :
sqlalchemy : 2.0.3
tables : 3.7.0
tabulate : 0.9.0
xarray : 2023.1.0
xlrd : 2.0.1
zstandard : 0.19.0
tzdata : None
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: