title: python extract elements from array
body: <p>I have an 8000-element 1D array. </p>
  
  <p>I want to obtain the following two arrays:</p>
  
  <ol>
  <li><p><code>test</code> contains the element with the index from <code>[1995:1999]</code>, <code>[3995:3999]</code>, <code>[5999:5999]</code>, <code>[7995:7999]</code>. </p></li>
  <li><p><code>train</code> should contains everything else. </p></li>
  </ol>
  
  <p>How should I do that? </p>
  
  <hr>
  
  <pre><code>idx = [1995,1996,1997,1998, 1999, 3995, 3996, 3997,3998, 3999, 5995, 5996, 5997, 5998, 5999, 7995, 7996, 7997, 7998, 7999]
  test = [X[i] for i in idx]
  
  train = [X[i] for i **not** in idx]
  </code></pre>