title: Is there a simple way for constructing an n by n array from two unequal arrays in python?
body: <p>I have two arrays</p>
  
  <pre><code>X_1 = [[1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 3, 1, 1, 1, 3, 1, 1, 1, 2, 1, 1],
  [ 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2],
  [0, 3, 3, 2, 3, 0, 0, 2, 1, 3, 2, 3, 3, 0, 2, 2, 0, 1, 0, 3, 3, 0, 2],
  [3, 0, 3, 3, 1, 2, 3, 3, 0, 3, 2, 3, 2, 3, 3, 3, 1, 3, 3, 3, 3, 1, 2, 0]]
  
  X_2 = [0,1,2,3]
  </code></pre>
  
  <p>I want to derive a 4 by 4 B array such that every <code>B[i,j]</code> element is the total number of values of <code>X_2[i]</code> in <code>X_1[j]</code></p>
  
  <p>Output:</p>
  
  <pre><code>B = [[0,16,3,2],
  [0,0,21,2],
  [7,2,6,7],
  [3,3,4,14]]
  </code></pre>