How to properly mask a numpy 2D array? : <p>Say I have a two dimensional array of coordinates that looks something like</p>

<p><code>x = array([[1,2],[2,3],[3,4]])</code></p>

<p>Previously in my work so far, I generated a mask that ends up looking something like</p>

<p><code>mask = [False,False,True]</code></p>

<p>When I try to use this mask on the 2D coordinate vector, I get an error</p>

<pre><code>newX = np.ma.compressed(np.ma.masked_array(x,mask))

&gt;&gt;&gt;numpy.ma.core.MaskError: Mask and data not compatible: data size 
   is 6, mask size is 3.`
</code></pre>

<p>which makes sense, I suppose. So I tried to simply use the following mask instead:</p>

<pre><code>mask2 = np.column_stack((mask,mask))
newX = np.ma.compressed(np.ma.masked_array(x,mask2))
</code></pre>

<p>And what I get is close:</p>

<p><code>&gt;&gt;&gt;array([1,2,2,3])</code></p>

<p>to what  I would expect (and want):</p>

<p><code>&gt;&gt;&gt;array([[1,2],[2,3]])</code></p>

<p>There must be an easier way to do this?</p>
