title: Index numpy arrays columns by another numpy array
body: <p>I am trying to index a 2d matrix in numpy so that I can get all rows but only particular columns given by another numpy array. It's something as following:</p>
  
  <pre><code>a = [0,1,1,2,0,2,1]
  
  d = [[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3],[1,2,3]]
  </code></pre>
  
  <p>I want to get all rows from d such that column is given by a. So for above example I want,</p>
  
  <pre><code>t = [1,2,2,3,1,3,2]
  </code></pre>
  
  <p>I tried some of the methods given on numpy documentation but am not able to get it.</p>
  
  <p>I think this is doable in matlab without any iteration. Can I do this is python without looping over something?</p>