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
Comment From: jreback
duplicate of #15697