title: Fastest way to search string in df column/ list
body: <p>I have two dfs:
  df_1: 100K rows.
  Each row represents information about a string (unique).
  The first column is that string.
  The rest of the columns are attributes about it.</p>
  <p>df_2: 10M rows.
  Each row represents information about a string (unique).
  The first column is that string.
  The rest of the columns are attributes about it.</p>
  <p>I want to check if string from df_1 exists in df_2. (do that for all strings in df_1).
  However, I want to minimize the running time. Are there ways to optimize the code I wrote:</p>
  <pre><code>def check_exists(keyword):
  
      keyword = keyword[0]
      print('check if keyword exists: ' + keyword)
      
      if (keyword in list_10m_keywords):
          df_1.loc[df_1['keyword'] == keyword, 'exists'] = 'TRUE'
          print('exists')
      else:
          print('not exists')
  
  
  # Load df_1
  # Save as global be used in other scopes
  global df_1 
  df_1 = pd.read_pickle('keywords_data_100k.pkl')
  
  
  # Load and convert df_2 column to list
  # Save as global be used in other scopes
  global list_10m_keywords
  df_2 = pd.read_pickle('keywords_data_10m.pkl')
  list_10m_keywords = df_2 ['keyword'].tolist()
  # Set not exists for all keywords up front
  df['exists'] = 'FALSE'
  
  # Iterate all rows in df_1, check if exists in df_2
  [check_exists(keyword) for keyword in zip(df_1['keyword'])]
  </code></pre>