title: Masking a pandas DataFrame with a numpy array vs DataFrame
body: <p>I want to use a 2D boolean mask to selectively alter some cells in a <code>pandas</code> <code>DataFrame</code>.  I noticed that I <em>cannot</em> use a <code>numpy</code> array (successfully) as the mask, but I <em>can</em> use a <code>DataFrame</code>.  More frustrating, however, is that I <em>don't get an error with the <code>numpy</code> approach</em>.</p>
  
  <p>For example,</p>
  
  <pre><code>df = pd.DataFrame({'A':[1,2,3,4], 
                     'B':[10,20,30,40]})
  
  mask_np = np.array([[True,True],
                      [False,False],
                      [True,False],
                      [False,True]])
  
  mask_pd = pd.DataFrame(mask_np, columns=['A','B'])
  </code></pre>
  
  <p>I would think either mask would return the values from <code>df</code> wherever the mask was <code>True</code>.  But instead, <code>df[mask_np]</code> produces</p>
  
  <pre><code>   A   B
  0  1  10
  0  1  10
  2  3  30
  3  4  40
  </code></pre>
  
  <p>which is not what I expect, nor can I explain.  On the other hand,  <code>df[mask_pd]</code> produces</p>
  
  <pre><code>     A     B
  0  1.0  10.0
  1  NaN   NaN
  2  3.0   NaN
  3  NaN  40.0
  </code></pre>
  
  <p>which is what I expect and want.</p>
  
  <p>Why can't I use the <code>numpy</code> mask? My internet search turned up nothing relevant.  Any explanation behind this difference would be greatly appreciated!</p>
  
  <p>[<code>pandas</code> version 0.20.3; Python 3.6.3]</p>