title: Split a numpy array using masking in python
body: <p>I have a numpy array <code>my_array</code> of size <code>100x20</code>. I want to create a function that receives as an input a 2d numpy array <code>my_arr</code> and an index <code>x</code> and will return two arrays one with size <code>1x20</code> <code>test_arr</code> and one with <code>99x20</code> <code>train_arr</code>. The vector <code>test_arr</code> will correspond to the row of the matrix <code>my_arr</code> with the index <code>x</code> and the <code>train_arr</code> will contain the rest rows. I tried to follow a solution using masking:</p>
  
  <pre><code>def split_train_test(my_arr, x):
  
     a = np.ma.array(my_arr, mask=False)
     a.mask[x, :] = True
     a = np.array(a.compressed())
     return a
  </code></pre>
  
  <p>Apparently this is not working as i wanted. How can i return a numpy array as a result and the train and test arrays properly?</p>