title: How do i slice an array for any size
body: <p>I have an array of 2D, called X and a 1D array for X's classes, what i want to do is slice the same amount of first N percent elements for each class and store inside a new array, for example, in a simple way without doing for loops:</p>
  <p>For the following X array which is 2D:</p>
  <pre><code>[[0.612515  0.385088 ]
   [0.213345  0.174123 ]
   [0.432596  0.8714246]
   [0.700230  0.730789 ]
   [0.455105  0.128509 ]
   [0.518423  0.295175 ]
   [0.659871  0.320614 ]
   [0.459677  0.940614 ]
   [0.823733  0.831789 ]
   [0.236175  0.10750  ]
   [0.379032  0.241121 ]
   [0.512535  0.8522193]
  </code></pre>
  <p>Output is 3.</p>
  <p>Then, i'd like to store the first 3 index that belongs to class 0 and first 3 elements that belongs to class 0 and maintain the occurence order of the indices, the following output:</p>
  <p>First 3 from each class:
  [1 0 0 1 0 1]</p>
  <pre><code>New_X = 
          [[0.612515  0.385088 ]
           [0.213345  0.174123 ]
           [0.432596  0.8714246]
           [0.700230  0.730789 ]
           [0.455105  0.128509 ]
           [0.518423  0.295175 ]]
  </code></pre>