-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: sometimes when using ~ and & operators for indexing it evaluated incorrectly #61052
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
Comments
I'm unable to reproduce this behavior both on 2.2.3 as well as dev. @adamszelestey-se do you have any stats on how often this line prints 10?
|
|
Yeah unfortunately it is really unpredicable for us too, but it occured pretty often, I would say 1 out of 2 cases.
We were running it as a regular python module in a poetry environment. I wanted to create the ticket if someone else also experience something like this, they could add more context, I can understand that you can not do anything with this until we figure out how to reproduce it. |
Am I correct in saying that you can never reproduce the bug with the code example that's in the OP? |
Unfortunately, you are correct meant to showcase that as the pseudo code if someone comes across the same issue This is the best I can give you, but can't reproduce the error at the moment:
` |
Thanks for clarifying. In the future, please make this more clear when you open an issue as maintainers spend time reproducing bugs that are reported. I would suggest to try to capture the output of I understand that it can be difficult to find a reproducer, but unfortunately we cannot do anything until one is produced. So closing for now. If you are able to come up with a reproducible example, post it here and we'll be glad to reopen! |
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
Edit [rhshadrach]: The code below does not reproduce the issue.
Issue Description
We don't know when and why this occurs. We werre looking for any rational explanation for hours. Anyone else experienced similar? How could this be possible?
(Environment: MacBook Pro 2023, Sequoia 15.3)
Expected Behavior
print(len(bool_df[(~bool_df["first"]) & (~bool_df["second"])])) # Print 1
Installed Versions
INSTALLED VERSIONS
commit : 0691c5c
python : 3.13.1
python-bits : 64
OS : Darwin
OS-release : 24.3.0
Version : Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6031
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8
pandas : 2.2.3
numpy : 2.2.3
pytz : 2025.1
dateutil : 2.9.0.post0
pip : 24.3.1
Cython : None
sphinx : None
IPython : 9.0.1
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
blosc : None
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
html5lib : None
hypothesis : None
gcsfs : None
jinja2 : 3.1.5
lxml.etree : 5.3.1
matplotlib : 3.10.1
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.5
pandas_gbq : None
psycopg2 : None
pymysql : None
pyarrow : 19.0.1
pyreadstat : None
pytest : 8.3.5
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.15.2
sqlalchemy : 2.0.38
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
xlsxwriter : None
zstandard : 0.23.0
tzdata : 2025.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: