<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="import pandas as pd
import numpy as np
from datetime import datetime,timedelta

threshold = np.datetime64(datetime.today()+timedelta(weeks=3))
df[threshold &lt; df['date']]
df[df['date'] &lt; threshold]
"><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">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">from</span> <span class="pl-s1">datetime</span> <span class="pl-k">import</span> <span class="pl-s1">datetime</span>,<span class="pl-s1">timedelta</span>

<span class="pl-s1">threshold</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">datetime64</span>(<span class="pl-s1">datetime</span>.<span class="pl-en">today</span>()<span class="pl-c1">+</span><span class="pl-en">timedelta</span>(<span class="pl-s1">weeks</span><span class="pl-c1">=</span><span class="pl-c1">3</span>))
<span class="pl-s1">df</span>[<span class="pl-s1">threshold</span> <span class="pl-c1">&lt;</span> <span class="pl-s1">df</span>[<span class="pl-s">'date'</span>]]
<span class="pl-s1">df</span>[<span class="pl-s1">df</span>[<span class="pl-s">'date'</span>] <span class="pl-c1">&lt;</span> <span class="pl-s1">threshold</span>]</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">As the two comparisons above show, they should present opposite results. Instead, both of them return the same result, as if df['date'] was always the first comparison operand.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">The picture below illustrates the issue. It was expected that the line <code class="notranslate">df[threshold &lt; df['date']]</code> would result in an empty DataFrame.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/5377246/27878548-fe104da6-6194-11e7-8f53-a6158d8851df.png"><img src="https://user-images.githubusercontent.com/5377246/27878548-fe104da6-6194-11e7-8f53-a6158d8851df.png" alt="screenshot from 2017-07-05 15-17-58" style="max-width: 100%;"></a></p>
<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: 2.7.12.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.4.0-83-generic<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.UTF-8<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.19.2<br>
nose: None<br>
pip: 9.0.1<br>
setuptools: 34.4.1<br>
Cython: None<br>
numpy: 1.12.1<br>
scipy: None<br>
statsmodels: None<br>
xarray: None<br>
IPython: None<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.0<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
matplotlib: 2.0.0<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: 4.5.3<br>
html5lib: None<br>
httplib2: 0.10.3<br>
apiclient: 1.6.2<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: None<br>
boto: 2.38.0<br>
pandas_datareader: None</p>
</details>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import datetime
s = pd.Series(pd.date_range('20130101',periods=3))
s-pd.Timestamp('20130101')
s-datetime.datetime(2013,1')"><pre class="notranslate"><code class="notranslate">import datetime
s = pd.Series(pd.date_range('20130101',periods=3))
s-pd.Timestamp('20130101')
s-datetime.datetime(2013,1')
</code></pre></div>
<p dir="auto">This fails as the datetime64 is not converted properly (because numpy datetime ops suck)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="s-np.datetime64('20130101')"><pre class="notranslate"><code class="notranslate">s-np.datetime64('20130101')
</code></pre></div>
<p dir="auto">e.g. <code class="notranslate">np.datetime64('20130101').astype('M8[ns]')</code> is a bug, no?</p>