<h4 dir="auto">Code Sample</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd
import datetime

# 4 examples:

df = pd.DataFrame({0: [1, None]})  # Works
df = pd.DataFrame({0: [None, 1]})  # Works

df = pd.DataFrame({0: [None, datetime.datetime.now()]})  # Exception

# Problem demonstration:
df != df.iloc[0]  # Works with numeric column, fails with NaT"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
<span class="pl-k">import</span> <span class="pl-s1">datetime</span>

<span class="pl-c"># 4 examples:</span>

<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-c1">0</span>: [<span class="pl-c1">1</span>, <span class="pl-c1">None</span>]})  <span class="pl-c"># Works</span>
<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-c1">0</span>: [<span class="pl-c1">None</span>, <span class="pl-c1">1</span>]})  <span class="pl-c"># Works</span>

<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-c1">0</span>: [<span class="pl-c1">None</span>, <span class="pl-s1">datetime</span>.<span class="pl-s1">datetime</span>.<span class="pl-en">now</span>()]})  <span class="pl-c"># Exception</span>

<span class="pl-c"># Problem demonstration:</span>
<span class="pl-s1">df</span> <span class="pl-c1">!=</span> <span class="pl-s1">df</span>.<span class="pl-s1">iloc</span>[<span class="pl-c1">0</span>]  <span class="pl-c"># Works with numeric column, fails with NaT</span></pre></div>
<h4 dir="auto">Problem description &amp; expected output.</h4>
<p dir="auto">In the above code, <strong>the final test <em>raises an exception</em></strong> with the <strong>datetime</strong> example, but <strong>works</strong> with the two <strong>numeric</strong> examples.</p>
<p dir="auto">I would expect the NaT case to behave like the numeric example.</p>
<p dir="auto">Note: a column with datetimes but <strong>no <code class="notranslate">NaT</code></strong> makes <code class="notranslate">df != df.iloc[0]</code> <strong>work as expected</strong>.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">I expect the result to be, like for numeric values, a dataframe that answers the question "is the value identical to that in the first row?" (as a dataframe with the same shape).</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;details&gt;
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.20.3
pytest: 3.2.2
pip: 9.0.1
setuptools: 36.3.0
Cython: 0.26.1
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 6.1.0
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.5.0a3
xlrd: 1.1.0
xlwt: 1.2.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: 4.6.0
html5lib: 0.9999999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None
&lt;/details&gt;"><pre class="notranslate"><code class="notranslate">&lt;details&gt;
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.20.3
pytest: 3.2.2
pip: 9.0.1
setuptools: 36.3.0
Cython: 0.26.1
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 6.1.0
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.5.0a3
xlrd: 1.1.0
xlwt: 1.2.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: 4.6.0
html5lib: 0.9999999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None
&lt;/details&gt;
</code></pre></div>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import pandas as pd
&gt;&gt;&gt; nat = pd.NaT
&gt;&gt;&gt; x = pd.Series([nat])
&gt;&gt;&gt; x.eq(nat)
0    False
dtype: bool
&gt;&gt;&gt; x == nat
0    False
dtype: bool
&gt;&gt;&gt; y = pd.DataFrame(dict(x=x))
&gt;&gt;&gt; y.eq(nat)
       x
0    NaT
&gt;&gt;&gt; y == nat
       x
0    True"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">nat</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">NaT</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>([<span class="pl-s1">nat</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span>.<span class="pl-en">eq</span>(<span class="pl-s1">nat</span>)
<span class="pl-c1">0</span>    <span class="pl-c1">False</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">bool</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span> <span class="pl-c1">==</span> <span class="pl-s1">nat</span>
<span class="pl-c1">0</span>    <span class="pl-c1">False</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">bool</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-en">dict</span>(<span class="pl-s1">x</span><span class="pl-c1">=</span><span class="pl-s1">x</span>))
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">y</span>.<span class="pl-en">eq</span>(<span class="pl-s1">nat</span>)
       <span class="pl-s1">x</span>
<span class="pl-c1">0</span>    <span class="pl-v">NaT</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">y</span> <span class="pl-c1">==</span> <span class="pl-s1">nat</span>
       <span class="pl-s1">x</span>
<span class="pl-c1">0</span>    <span class="pl-c1">True</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">Comparisons in a dataframe containing a single nat give incorrect answers. Note this occurs with both datetime and timedelta nats.</p>
<h4 dir="auto">Expected Output</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="0    False
dtype: bool

0    False
dtype: bool

       x
0  False

       x
0  False"><pre class="notranslate"><span class="pl-c1">0</span>    <span class="pl-c1">False</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">bool</span>

<span class="pl-c1">0</span>    <span class="pl-c1">False</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">bool</span>

       <span class="pl-s1">x</span>
<span class="pl-c1">0</span>  <span class="pl-c1">False</span>

       <span class="pl-s1">x</span>
<span class="pl-c1">0</span>  <span class="pl-c1">False</span></pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.5.2.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.9.8-100.fc24.x86_64<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: C<br>
LANG: C<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.19.0+579.g4ce9c0c<br>
pytest: 3.0.5<br>
pip: 9.0.1<br>
setuptools: 27.2.0<br>
Cython: 0.25.2<br>
numpy: 1.11.3<br>
scipy: 0.18.1<br>
xarray: 0.9.1<br>
IPython: 4.2.0<br>
sphinx: 1.5.1<br>
patsy: 0.4.1<br>
dateutil: 2.6.0<br>
pytz: 2016.10<br>
blosc: None<br>
bottleneck: 1.2.0<br>
tables: 3.3.0<br>
numexpr: 2.6.2<br>
feather: None<br>
matplotlib: 2.0.0<br>
openpyxl: 2.4.1<br>
xlrd: 1.0.0<br>
xlwt: 1.2.0<br>
xlsxwriter: 0.9.6<br>
lxml: 3.7.2<br>
bs4: 4.5.3<br>
html5lib: 0.999<br>
sqlalchemy: 1.1.5<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.4<br>
s3fs: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>