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: NaT value comparation always result in True within DataFrame but not Series #18816

Closed
sinowood opened this issue Dec 18, 2017 · 1 comment
Labels
Datetime Datetime data dtype Duplicate Report Duplicate issue or pull request Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@sinowood
Copy link

Code Sample, a copy-pastable example

# Your code here
df = pd.DataFrame([[pd.Timestamp(2017,12,17), pd.Timestamp(2017,12,18)], [pd.Timestamp(2017,12,31), pd.NaT]])

In [7]: df
Out[7]:
           0          1
0 2017-12-17 2017-12-18
1 2017-12-31        NaT

In [8]: df < pd.Timestamp(2017,1,1)
Out[8]:
       0      1
0  False  False
1  False   True

In [9]: df[1] < pd.Timestamp(2017,1,1)
Out[9]:
0    False
1    False

Problem description

When comparing a dataframe of dtype Timestamp to a scalar value (Timestamp or datetime), the result to NaT is always True no matter what operator is used(==, <, >, ...).

But it is not the case when compares a series of Timestamps.

Expected Output

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.6.2.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 70 Stepping 1, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None

pandas: 0.21.1
pytest: 3.0.5
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.13.3
scipy: 0.18.1
pyarrow: None
xarray: 0.9.6
IPython: 6.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: 1.2.0
tables: 3.4.2
numexpr: 2.6.1
feather: None
matplotlib: 2.1.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.2
bs4: 4.5.3
html5lib: None
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.4
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: 0.5.0

@jreback
Copy link
Contributor

jreback commented Dec 18, 2017

duplicate of #15697

@jreback jreback closed this as completed Dec 18, 2017
@jreback jreback added Duplicate Report Duplicate issue or pull request Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Datetime Datetime data dtype labels Dec 18, 2017
@jreback jreback added this to the No action milestone Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Duplicate Report Duplicate issue or pull request Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

No branches or pull requests

2 participants