title: All indices of each unique element in a list python
body: <p>I'm working with a very large data set (about 75 million entries) and I'm trying to shorten the length of time that running my code takes by a significant margin (with a loop right now it will take a couple days) and keep memory usage extremely low.</p>
  
  <p>I have two numpy arrays (<code>clients</code> and <code>units</code>) of the same length. My goal is to get a list of every index that a value occurs in my first list (<code>clients</code>) and then find a sum of the entries in my second list at each of those indices.</p>
  
  <p>This is what I've tried (<code>np</code> is the previously imported numpy library)</p>
  
  <pre><code># create a list of each value that appears in clients
  unq = np.unique(clients)
  arr = np.zeros(len(unq))
  tmp = np.arange(len(clients))
  # for each unique value i in clients
  for i in range(len(unq)) :
      #create a list inds of all the indices that i occurs in clients
      inds = tmp[clients==unq[i]]
      # add the sum of all the elements in units at the indices inds to a list
      arr[i] = sum(units[inds])
  </code></pre>
  
  <p>Does anyone know a method that will allow me to find these sums without looping through each element in <code>unq</code>?</p>