Skip to content
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

BUG: DataFrame dtype != comparison fails #55800

Closed
2 of 3 tasks
avnishbm opened this issue Nov 2, 2023 · 2 comments
Closed
2 of 3 tasks

BUG: DataFrame dtype != comparison fails #55800

avnishbm opened this issue Nov 2, 2023 · 2 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@avnishbm
Copy link

avnishbm commented Nov 2, 2023

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

import pandas as pd
from datetime import date

df = pd.DataFrame(['2023-11-01','2023-01-01' '2022-01-02'] , columns=['date']) 

print (df.dtypes['date'])

print (df.dtypes['date'] != date)

print (df.dtypes['date'] is not date)

Issue Description

When we run the above code, we see that the datatype of 'date' column is object, but when compared with date type using != it returns False in place of True. But the same comparison done using "is not" returns True! Please note that that this was working in earlier versions e.g. in pandas 1.x

Expected Behavior

When comparing dtype object with date using != should have returned True.

Installed Versions

INSTALLED VERSIONS

commit : a60ad39
python : 3.9.17.final.0
python-bits : 64
OS : Darwin
OS-release : 21.6.0
Version : Darwin Kernel Version 21.6.0: Wed Oct 4 23:55:28 PDT 2023; root:xnu-8020.240.18.704.15~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.1.2
numpy : 1.24.2
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 67.8.0
pip : 23.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.2
html5lib : 1.1
pymysql : None
psycopg2 : 2.9.9
jinja2 : 3.1.2
IPython : 7.28.0
pandas_datareader : 0.10.0
bs4 : 4.12.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.6.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 3.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.9.2
sqlalchemy : 2.0.15
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
None

@avnishbm avnishbm added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 2, 2023
@jbrockmendel
Copy link
Member

This boils down to the numpy behavior:

from datetime import date
import numpy as np

dtype = np.dtype(object)

>>> dtype == date
True

@mroeschke
Copy link
Member

Thanks for the report, but since this is an upstream issue closing here. Feel free to raise an issue in numpy if you believe the behavior should change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

3 participants