title: Most efficient way of conditional pairwise row operations in a pandas DataFrame
body: <p>I have a pandas DataFrame 'df' containing about 10<sup>6</sup> rows. Now I want to execute the following code:</p>
  
  <pre><code>c = []
  for ind, a in df.iterrows():
      for ind, b in df.iterrows():
          if a.hit_id &lt; b.hit_id and a.layer_id != b.layer_id :
              c.append(dist(a, b))
  c = numpy.array(c)
  </code></pre>
  
  <p>What is the most efficient way of doing this?</p>