<p dir="auto">Having seen some inconsistent results from processing DataFrames - literally, running scripts over static data would generate different outcomes - we were able to boil down the following example:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="def compare(df):
    df1 = df.query('x &lt; 2000')
    df2 = df.query('x &lt; 2000')
    return df1.equals(df2)"><pre class="notranslate"><span class="pl-k">def</span> <span class="pl-en">compare</span>(<span class="pl-s1">df</span>):
    <span class="pl-s1">df1</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-en">query</span>(<span class="pl-s">'x &lt; 2000'</span>)
    <span class="pl-s1">df2</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-en">query</span>(<span class="pl-s">'x &lt; 2000'</span>)
    <span class="pl-k">return</span> <span class="pl-s1">df1</span>.<span class="pl-en">equals</span>(<span class="pl-s1">df2</span>)</pre></div>
<p dir="auto">If I understand correctly, calling <code class="notranslate">compare</code> should never return false and yet it does, randomly:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; df = pd.DataFrame({'x': range(100000), 'y': range(100000)})
&gt;&gt;&gt; for i in xrange(1000):
...     if not compare(df):
...         print ('failed at iteration', i)
...
failed at iteration 10
failed at iteration 66
failed at iteration 80
failed at iteration 141
failed at iteration 149
            ...
failed at iteration 878
failed at iteration 999"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; df = pd.DataFrame({'x': range(100000), 'y': range(100000)})
&gt;&gt;&gt; for i in xrange(1000):
...     if not compare(df):
...         print ('failed at iteration', i)
...
failed at iteration 10
failed at iteration 66
failed at iteration 80
failed at iteration 141
failed at iteration 149
            ...
failed at iteration 878
failed at iteration 999
</code></pre></div>
<p dir="auto">This seems like a defect in query?</p>
<p dir="auto">Relevant versions:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;python --version
Python 2.7.11 :: Anaconda 2.4.0 (64-bit)
&gt;systeminfo | findstr /B /C:&quot;OS Name&quot; /C:&quot;OS Version&quot; /C:&quot;System Type&quot;
OS Name:                   Microsoft Windows 8.1 Pro
OS Version:                6.3.9600 N/A Build 9600
System Type:               x64-based PC"><pre class="notranslate"><code class="notranslate">&gt;python --version
Python 2.7.11 :: Anaconda 2.4.0 (64-bit)
&gt;systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type"
OS Name:                   Microsoft Windows 8.1 Pro
OS Version:                6.3.9600 N/A Build 9600
System Type:               x64-based PC
</code></pre></div>
<p dir="auto">We are observing some inconsistent behaviour of the dataframe <code class="notranslate">query</code> method under windows.</p>
<p dir="auto">I enclose a smallish (3600 rows) dataframe where we find the issue.</p>
<p dir="auto">The following code fails randomly under Windows, but seems to work smoothly on Mac:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd

df = pd.read_csv(&quot;pd_bug.txt&quot;)

for x in df.A.unique():
    try:
        assert len(df.query('(A == @x) | (B == @x)')) == len(df[(df.A == x) | (df.B == x)])
    except AssertionError:
        print x"><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-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">read_csv</span>(<span class="pl-s">"pd_bug.txt"</span>)

<span class="pl-k">for</span> <span class="pl-s1">x</span> <span class="pl-c1">in</span> <span class="pl-s1">df</span>.<span class="pl-v">A</span>.<span class="pl-en">unique</span>():
    <span class="pl-k">try</span>:
        <span class="pl-k">assert</span> <span class="pl-en">len</span>(<span class="pl-s1">df</span>.<span class="pl-en">query</span>(<span class="pl-s">'(A == @x) | (B == @x)'</span>)) <span class="pl-c1">==</span> <span class="pl-en">len</span>(<span class="pl-s1">df</span>[(<span class="pl-s1">df</span>.<span class="pl-v">A</span> <span class="pl-c1">==</span> <span class="pl-s1">x</span>) <span class="pl-c1">|</span> (<span class="pl-s1">df</span>.<span class="pl-v">B</span> <span class="pl-c1">==</span> <span class="pl-s1">x</span>)])
    <span class="pl-k">except</span> <span class="pl-v">AssertionError</span>:
        <span class="pl-k">print</span> <span class="pl-s1">x</span></pre></div>
<p dir="auto">We are observing a failure every other run (often with two or three values failing).<br>
Here is the output of <code class="notranslate">pd.show_versions()</code> on the failing machine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.17.1
nose: 1.3.7
pip: 7.1.2
setuptools: 19.1.1
Cython: 0.23.4
numpy: 1.10.1
scipy: 0.16.0
statsmodels: 0.6.1
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.4
matplotlib: 1.5.0
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.4.4
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.9
pymysql: None
psycopg2: None
Jinja2: None"><pre class="notranslate"><code class="notranslate">INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.17.1
nose: 1.3.7
pip: 7.1.2
setuptools: 19.1.1
Cython: 0.23.4
numpy: 1.10.1
scipy: 0.16.0
statsmodels: 0.6.1
IPython: 4.0.1
sphinx: 1.3.1
patsy: 0.4.0
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.4.4
matplotlib: 1.5.0
openpyxl: 2.2.6
xlrd: 0.9.4
xlwt: 1.0.0
xlsxwriter: 0.7.7
lxml: 3.4.4
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.9
pymysql: None
psycopg2: None
Jinja2: None
</code></pre></div>
<p dir="auto"><a href="https://github.com/pydata/pandas/files/87187/pd_bug.txt">pd_bug.txt</a></p>