title: Iterate over all pairwise combinations of numpy array columns
body: <p>I have an numpy array of size </p>
  
  <pre><code>arr.size = (200, 600, 20). 
  </code></pre>
  
  <p>I want to compute <code>scipy.stats.kendalltau</code> on every pairwise combination of the last two dimensions. For example:</p>
  
  <pre><code>kendalltau(arr[:, 0, 0], arr[:, 1, 0])
  kendalltau(arr[:, 0, 0], arr[:, 1, 1])
  kendalltau(arr[:, 0, 0], arr[:, 1, 2])
  ...
  kendalltau(arr[:, 0, 0], arr[:, 2, 0])
  kendalltau(arr[:, 0, 0], arr[:, 2, 1])
  kendalltau(arr[:, 0, 0], arr[:, 2, 2])
  ...
  ...
  kendalltau(arr[:, 598, 20], arr[:, 599, 20])
  </code></pre>
  
  <p>such that I cover all combinations of <code>arr[:, i, xi]</code> with <code>arr[:, j, xj]</code> with <code>i &lt; j</code> and <code>xi in [0,20)</code>, <code>xj in [0, 20)</code>. This is <code>(600 choose 2) * 400</code> individual calculations, but since each takes about <code>0.002 s</code> on my machine, it shouldn't take much longer than a day with the multiprocessing module. </p>
  
  <p>What's the best way to go about iterating over these columns (with <code>i&lt;j</code>)? I figure I should avoid something like</p>
  
  <pre><code>for i in range(600):
      for j in range(i+1, 600):
          for xi in range(20):
              for xj in range(20):
  </code></pre>
  
  <p>What is the most numpythonic way of doing this?</p>
  
  <p><strong>Edit:</strong> I changed the title since Kendall Tau isn't really important to the question. I realize I could also do something like</p>
  
  <pre><code>import itertools as it
  for i, j in it.combinations(xrange(600), 2):
      for xi, xj in product(xrange(20), xrange(20)):
  </code></pre>
  
  <p>but there's got to be a better, more vectorized way with numpy.</p>