title: Unexpected slow iteration over DataFrame rows
body: <p>I want to compare all lines of a csv file against each other. What I want to do is to get the squared sum of the differences between each two rows:</p>
  <p><code>np.sum((row_i-row_j)**2)</code></p>
  <p>I did this using python csv library and it was ok, but I want to use pandas and for some reason, pandas is extremely slow.</p>
  <p>My code using csv:</p>
  <pre><code>with open(filename) as file:
      reader = csv.reader(file, delimiter=' ', skipinitialspace=True)
      header = reader.__next__()
      table = list(reader)
  
  for i in range(len(table)-1):
      row_i = np.array(table[i][2:-2], dtype='double')
      for j in range(i+1, len(table)):
          row_j = np.array(table[j][2:-2], dtype='double')
          u = np.sum((row_i - row_j)**2)
  </code></pre>
  <p>My code using pandas:</p>
  <pre><code>df = pd.read_csv(filename, delim_whitespace=True)
  lines_to_remove2=set()
  for i in range(len(df)-1):
      row_i = df.iloc[i][2:-2].values
      for j in range(i+1,len(df)):
          row_j = df.iloc[j][2:-2].values
          u = np.sum((row_i - row_j)**2)
  </code></pre>
  <p>As you can see I'm not doing any comparation yet, I'm only assigning values for each row. I will further use the value of <code>u</code> to decide which lines will be deleted.
  My file has 480 rows which means there are 480*479 iterations, which is not so much. When I iterate over a list, it takes me less than 1s to iterate over all rows, but it takes me many seconds to do it with a pandas.DataFrame. Am I doing something wrong? Is there a faster way of doing this in pandas?</p>