title: Iterating over multiple pandas dataframe is slow
body: <p>I'm trying to find the number of similar words for all rows in Dataframe1 for every single row with words in Dataframe 2. </p>
  
  <p>Based on the similarities I want to create a new data frame with where <br>columns = N rows of dataframe2 
  <br>values = similarity.</p>
  
  <p>My current code is working, but it runs very slow. I'm not sure how to optimize it...</p>
  
  <pre><code>df = pd.DataFrame([])
  
  for x in range(10000):
      save = {}  
      terms_1 = data['text_tokenized'].iloc[x]
      save['code'] = data['code'].iloc[x]
  
      for y in range(3000):
          terms_2 = data2['terms'].iloc[y]
          similar_n = len(list(terms_2.intersection(terms_1)))
          save[data2['code'].iloc[y]] = similar_n
  
      df = df.append(pd.DataFrame([save]))
  </code></pre>
  
  <p><strong>Update: new code (still running slow)</strong></p>
  
  <pre><code>def get_sim(x, terms):
      similar_n = len(list(x.intersection(terms)))
      return similar_n
  
  for index in icd10_terms.itertuples():
      code,terms = index[1],index[2]
      data[code] = data['text_tokenized'].apply(get_sim, args=(terms,))
  </code></pre>