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

Closed
philippegr opened this issue Aug 8, 2018 · 3 comments · Fixed by #22163
Closed

Problem in comparisons for DataFrame with pd.NaT #22242

philippegr opened this issue Aug 8, 2018 · 3 comments · Fixed by #22163
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Timeseries
Milestone

Comments

@philippegr
Copy link

philippegr 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)]])
print(tmp.iloc[0]==dt.datetime(1999,12,31))
print(tmp==dt.datetime(1999,12,31))

Output
(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]
INSTALLED VERSIONS

commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-30-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

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

@jbrockmendel
Copy link
Member

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

@philippegr
Copy link
Author

Just updated

@jbrockmendel
Copy link
Member

Thanks. This will be fixed by #22163.

@gfyoung gfyoung added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Timeseries labels Aug 8, 2018
@jreback jreback added this to the 0.24.0 milestone Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Timeseries
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants