-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: isin() give incorrect results for uint64 columns #46485
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
take |
It seems when I run it and print the output it says that both of them are empty dataframes, could that 0 just be so that the data can be viewed? I may be misunderstanding the bug, but to me it seems like it could be intended behavior. |
In real case i wanted to filer out DataFrame by some values, but it keeps returning wrong values, what not supposed to be in it. So i believe, what is not for viewing purpose, it should return DataFrame, that contains values from isin(). And if there is none, it should return empty DataFrame. For example. this is expected behavior test_df[test_df['a'].isin([1])]
Empty DataFrame
Columns: [a]
Index: [] I constantly reproduce bug in two different os and in random online python interpreter. And i find out, that bug not present in version 1.1.5. |
Apologies for asking, but could you restate that? I am having a little trouble understanding what you mean in your explanation. |
Oh, sorry. Let me try a more clear example import pandas as pd
import numpy as np
test_df = pd.DataFrame([{'a': 1378774140726870442}], dtype=np.uint64)
print(1378774140726870442 == 1378774140726870528)
False
print(test_df['a'].isin([1378774140726870528])[0])
True
print(test_df['a'].isin([1])[0])
False I expected tha isin() return True only if any value in column presented in list, that is argument for isin(). In this example isin() sometimes returns true for clearly different numbers. I encountered this behaviour only for unit64 column and for big enough numbers. And in pandas==1.1.15 isn() working as expected. |
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
I have column in uin64 and want to check if values in some list. but isin returning incorrect results. I suspect where some Implicit type conversion, cause I was't able to reproduce for other types
Expected Behavior
For examples I expected empty DataFrame in both cases
Installed Versions
INSTALLED VERSIONS
commit : 06d2301
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 4.19.100-23
Version : #1 SMP Fri Jan 31 16:16:00 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : C.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.1
numpy : 1.21.2
pytz : 2020.5
dateutil : 2.8.2
pip : 20.0.2
setuptools : 58.2.0
Cython : 0.29.24
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.3
html5lib : None
pymysql : None
psycopg2 : 2.9.1
jinja2 : 3.0.2
IPython : 7.28.0
pandas_datareader: None
bs4 : 4.10.0
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.4.3
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : 1.4.25
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: