title: How to extract values from a python list or numpy array using conditional checks by the application of numpy vectorization?
body: <p>I have the following code and I want to extract certain values from other lists that depends upon the given condition. But my data sets are huge ~ 1 million values in each list. Therefore this method of nested loop takes too long. Is there a vectorized or faster approach using Numpy that I can use to speed up my code as well as use less memory?</p>
  
  <pre><code>import random
  import numpy as np
  
  x=[random.randrange(0,10) for _ in range(0,100)]
  y=[random.randrange(0,10) for _ in range(0,100)]
  z=[random.randrange(0,10) for _ in range(0,100)]
  
  x_unique=np.unique(x)
  
  xx_list=[]
  y_list=[]
  z_list=[]
  
  for i in range(len(x_unique)):
      xx_list.append([])
      y_list.append([])
      z_list.append([])
  
  for ii, i in enumerate(x_unique):
          for j,k in enumerate(x):
              if i == k:
                  xx_list[ii].append(x[j])
                  y_list[ii].append(y[j])
                  z_list[ii].append(z[j])
  </code></pre>
  
  <p>[EDIT: added an example of what to expect]</p>
  
  <p>In the lists: y_list and z_list, I want to store values that correspond to same index numbers as stored in xx_list.</p>
  
  <p>For example consider the following example lists:</p>
  
  <pre><code>x = [0.1,0.1,1,0.1,2,1,0.1]
  y = [1.1,2.1,3,4,5,6,7]
  z = [10,11,12,13.1,14,15,16]
  </code></pre>
  
  <p>Therefore, x_unique is the following:</p>
  
  <pre><code>x_unique = [0.1,1,2]
  </code></pre>
  
  <p>xx_list, y_list and z_list should contain the following:</p>
  
  <pre><code>xx_list = [[0.1,0.1,0.1,0.1],[1,1],[2]]
  y_list = [[1.1,2.1,4,7],[3,6],[5]]
  z_list = [[10,11,13.1,16],[12,15],[14]]
  </code></pre>