Skip to content

BUG: Compare type int64 with Int64 fails #43038

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

Closed
2 of 3 tasks
ChiQiao opened this issue Aug 14, 2021 · 10 comments
Closed
2 of 3 tasks

BUG: Compare type int64 with Int64 fails #43038

ChiQiao opened this issue Aug 14, 2021 · 10 comments
Assignees
Labels
Compat pandas objects compatability with Numpy or Python functions Dtype Conversions Unexpected or buggy dtype conversions good first issue Needs Tests Unit test(s) needed to prevent regressions
Milestone

Comments

@ChiQiao
Copy link

ChiQiao commented Aug 14, 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.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

pd.api.types.pandas_dtype("int64") == "Int64"

Problem description

The code above fails (TypeError: data type 'Int64' not understood) while the following cases pass:

pd.api.types.pandas_dtype("int64") == "int64"
pd.api.types.pandas_dtype("Int64") == "Int64"
pd.api.types.pandas_dtype("Int64") == "int64"

Expected Output

False

Output of pd.show_versions()

INSTALLED VERSIONS

commit : c7f7443
python : 3.7.11.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : None.None

pandas : 1.3.1
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.2
setuptools : 52.0.0.post20210125
Cython : 0.29.24
pytest : 6.1.2
hypothesis : 6.14.1
sphinx : 4.0.2
blosc : None
feather : None
xlsxwriter : 1.4.4
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : 1.0.2
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.22.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 2021.07.0
fastparquet : None
gcsfs : None
matplotlib : 3.4.2
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : 3.0.0
pyxlsb : None
s3fs : 0.4.2
scipy : 1.6.2
sqlalchemy : 1.4.22
tables : 3.6.1
tabulate : 0.8.9
xarray : 0.19.0
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.53.0

@ChiQiao ChiQiao added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 14, 2021
@jbrockmendel
Copy link
Member

This is an issue with np.dtpye.__eq__, should be fixed by numpy/numpy#19228

@simonjayhawkins
Copy link
Member

can't reproduce on pandas 1.2.5 onwards.

>>> pd.__version__
'1.2.5'
>>> pd.api.types.pandas_dtype("int64") == "Int64"
False

Expected Output

True

numpy int dtypes can't hold missing values, so False seem more appropriate.

@simonjayhawkins simonjayhawkins added Dtype Conversions Unexpected or buggy dtype conversions and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 16, 2021
@ChiQiao
Copy link
Author

ChiQiao commented Aug 16, 2021

Thanks @jbrockmendel and @simonjayhawkins for the input

can't reproduce on pandas 1.2.5 onwards.

Since it may be a bug from numpy, I wonder which numpy version you were using?
Also, I wonder if you were able to reproduce the bug given the environment I posted (pandas 1.3.1, numpy 1.20.3)?

numpy int dtypes can't hold missing values, so False seem more appropriate.

Yes, that was a typo on my side. I've updated the description.

@kwhkim
Copy link
Contributor

kwhkim commented Aug 30, 2021

In my case, no bug found. (But I can not understand how it can be a bug from numpy when numpy does not support integer NAs. Isn't it the reason that they named integer NA as pd.NA?)

>>> pd.api.types.pandas_dtype("int64") == "Int64"
False
>>> pd.__version__
'1.3.1'
>>> np.__version__
'1.21.1'

@mzeitlin11
Copy link
Member

See discussion in #43993 - this is fixed for newer versions of numpy, contributions welcome to add a regression test!

@mzeitlin11 mzeitlin11 added Compat pandas objects compatability with Numpy or Python functions good first issue Needs Tests Unit test(s) needed to prevent regressions and removed Bug labels Oct 13, 2021
@mzeitlin11 mzeitlin11 added this to the Contributions Welcome milestone Oct 13, 2021
@paulvdbles
Copy link

take

@ata-turhan
Copy link
Contributor

take

@ata-turhan
Copy link
Contributor

Can you give me an example for how to add a regression test for this issue? Thank you :)

@mzeitlin11
Copy link
Member

Can you give me an example for how to add a regression test for this issue? Thank you :)

I'd recommend looking at closed good first issues about testing (for example from https://github.com/pandas-dev/pandas/issues?q=is%3Aissue+label%3A%22good+first+issue%22+is%3Aclosed+label%3A%22Needs+Tests%22). If you look at some pull requests which close the issue, those should be good examples

@simonjayhawkins
Copy link
Member

closing as tests added in #44840

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Dtype Conversions Unexpected or buggy dtype conversions good first issue Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants