<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="df = pd.DataFrame.from_dict({'A': {(42, 'foo', 4): 0, (42, 'foo', 9): 0},
 'B': {(42, 'foo', 4): 0, (42, 'foo', 9): 0},
 'C': {(42, 'foo', 4): 0, (42, 'foo', 9): 0},
 'D': {(42, 'foo', 4): 0, (42, 'foo', 9): 0},
 'E': {(42, 'foo', 4): 0, (42, 'foo', 9): 0},
 'F': {(42, 'foo', 4): 0, (42, 'foo', 9): 0},
 'G': {(42, 'foo', 4): 1, (42, 'foo', 9): 1}})

print(df.reindex(pd.RangeIndex(-1, 11), level=2, fill_value=0))"><pre class="notranslate"><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-en">from_dict</span>({<span class="pl-s">'A'</span>: {(<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">4</span>): <span class="pl-c1">0</span>, (<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">9</span>): <span class="pl-c1">0</span>},
 <span class="pl-s">'B'</span>: {(<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">4</span>): <span class="pl-c1">0</span>, (<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">9</span>): <span class="pl-c1">0</span>},
 <span class="pl-s">'C'</span>: {(<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">4</span>): <span class="pl-c1">0</span>, (<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">9</span>): <span class="pl-c1">0</span>},
 <span class="pl-s">'D'</span>: {(<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">4</span>): <span class="pl-c1">0</span>, (<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">9</span>): <span class="pl-c1">0</span>},
 <span class="pl-s">'E'</span>: {(<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">4</span>): <span class="pl-c1">0</span>, (<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">9</span>): <span class="pl-c1">0</span>},
 <span class="pl-s">'F'</span>: {(<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">4</span>): <span class="pl-c1">0</span>, (<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">9</span>): <span class="pl-c1">0</span>},
 <span class="pl-s">'G'</span>: {(<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">4</span>): <span class="pl-c1">1</span>, (<span class="pl-c1">42</span>, <span class="pl-s">'foo'</span>, <span class="pl-c1">9</span>): <span class="pl-c1">1</span>}})

<span class="pl-en">print</span>(<span class="pl-s1">df</span>.<span class="pl-en">reindex</span>(<span class="pl-s1">pd</span>.<span class="pl-v">RangeIndex</span>(<span class="pl-c1">-</span><span class="pl-c1">1</span>, <span class="pl-c1">11</span>), <span class="pl-s1">level</span><span class="pl-c1">=</span><span class="pl-c1">2</span>, <span class="pl-s1">fill_value</span><span class="pl-c1">=</span><span class="pl-c1">0</span>))</pre></div>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="          A  B  C  D  E  F  G
42 foo 4  0  0  0  0  0  0  1
       9  0  0  0  0  0  0  1"><pre class="notranslate"><code class="notranslate">          A  B  C  D  E  F  G
42 foo 4  0  0  0  0  0  0  1
       9  0  0  0  0  0  0  1
</code></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">I would expect that the resulting dataframe have 12 rows, with indices <code class="notranslate">(42, 'foo', i)</code> for <code class="notranslate">i</code> from <code class="notranslate">-1</code> to <code class="notranslate">10</code>.</p>
<p dir="auto">Apologies if I am just misunderstanding something. I haven't managed to find any information in the docs on the reason for the current behavior.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.14.24-1-MANJARO
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: None
pip: 9.0.1
setuptools: 38.5.1
Cython: 0.27.3
numpy: 1.14.0
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2018.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None"><pre class="notranslate"><code class="notranslate">INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.14.24-1-MANJARO
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: None
pip: 9.0.1
setuptools: 38.5.1
Cython: 0.27.3
numpy: 1.14.0
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2018.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
</code></pre></div>
</details>
<p dir="auto">Under Windows 8 (x64), with Pandas v0.17.0 (from Anaconda) and up, Pandas.DataFrame.where() function is found to behave sporadically, sometimes returning the expected result and sometimes returning a dataframe filled with zeros.</p>
<p dir="auto">The following code demonstrates this behavior, observed for dataframes that have larger than 361 rows and columns.</p>
<p dir="auto">I observed that this problem does NOT exist in Pandas v0.16.2 on the same machine (Windows 8 x64, Anaconda), and in Pandas v0.17.1 under Mac OS (Anaconda).</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import pandas as pd

n = 400
n_trials = 1000

df_1 = pd.DataFrame(data=np.random.random((n,n)), index=np.arange(0,n), columns=np.arange(0,n))
df_2 = pd.DataFrame(data=np.random.random((n,n)), index=np.arange(0,n), columns=np.arange(0,n))

count = 0
for i in xrange(0,n_trials):
  res = df_1.where(df_2 &gt; 0.5)
  if (res &lt; 1e-6).all().all():
    count += 1
print &quot;number of unexpected cases: &quot;, count"><pre class="notranslate"><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">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>

<span class="pl-s1">n</span> <span class="pl-c1">=</span> <span class="pl-c1">400</span>
<span class="pl-s1">n_trials</span> <span class="pl-c1">=</span> <span class="pl-c1">1000</span>

<span class="pl-s1">df_1</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">random</span>((<span class="pl-s1">n</span>,<span class="pl-s1">n</span>)), <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">0</span>,<span class="pl-s1">n</span>), <span class="pl-s1">columns</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">0</span>,<span class="pl-s1">n</span>))
<span class="pl-s1">df_2</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">random</span>((<span class="pl-s1">n</span>,<span class="pl-s1">n</span>)), <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">0</span>,<span class="pl-s1">n</span>), <span class="pl-s1">columns</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">0</span>,<span class="pl-s1">n</span>))

<span class="pl-s1">count</span> <span class="pl-c1">=</span> <span class="pl-c1">0</span>
<span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-en">xrange</span>(<span class="pl-c1">0</span>,<span class="pl-s1">n_trials</span>):
  <span class="pl-s1">res</span> <span class="pl-c1">=</span> <span class="pl-s1">df_1</span>.<span class="pl-en">where</span>(<span class="pl-s1">df_2</span> <span class="pl-c1">&gt;</span> <span class="pl-c1">0.5</span>)
  <span class="pl-k">if</span> (<span class="pl-s1">res</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">1e-6</span>).<span class="pl-en">all</span>().<span class="pl-en">all</span>():
    <span class="pl-s1">count</span> <span class="pl-c1">+=</span> <span class="pl-c1">1</span>
<span class="pl-k">print</span> <span class="pl-s">"number of unexpected cases: "</span>, <span class="pl-s1">count</span></pre></div>
<p dir="auto">returns non-zero counts.</p>