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

Problem in comparisons for DataFrame with pd.NaT #22242

philippegr opened this issue Aug 8, 2018 · 3 comments


None yet
4 participants
Copy link

commented Aug 8, 2018

Code Sample, a copy-pastable example if possible

import pandas as pd
import datetime as dt

tmp = pd.DataFrame.from_records(data=[[dt.datetime(1999,12,31), pd.NaT], [pd.NaT, dt.datetime(1999,12,31)]])

(First print statement Series comparison)
0 True
1 False

(Second print statement DataFrame)
0 1
0 True True
1 True True

Problem description

When comparing a DataFrame containing pd.NaT (among other datetimes) with a single datetime results appears as True (second print statement).
This is different from the behaviour for Series (first print statement), which corresponds to what one would expect.

Expected Output

Second print statement should be
True False
False True

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

commit: None
python-bits: 64
OS: Linux
OS-release: 4.15.0-30-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None

pandas: 0.23.4
pytest: None
pip: 10.0.1
setuptools: 39.2.0
Cython: None
numpy: 1.15.0
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None


This comment has been minimized.

Copy link

commented Aug 8, 2018

For clarification, can you please post the full output you get


This comment has been minimized.

Copy link

commented Aug 8, 2018

Just updated


This comment has been minimized.

Copy link

commented Aug 8, 2018

Thanks. This will be fixed by #22163.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.