title: Fuzzy regex match on million rows Pandas df
body: <p>I am trying to check for fuzzy match between a string column and a reference list. The string series contains over 1 m rows and the reference list contains over 10 k entries.</p>
  <p>For eg:</p>
  <pre><code>df['NAMES'] = pd.Series(['ALEXANDERS', 'NOVA XANDER', 'SALA MANDER', 'PARIS HILTON', 'THE HARIS DOWNTOWN', 'APARISIAN', 'PARIS', 'MARIN XO']) # 1mil rows
  
  ref_df['REF_NAMES'] = pd.Series(['XANDER','PARIS']) #10 k rows
  
  ###Output should look like 
  
  df['MATCH'] = pd.Series([Nan, 'XANDER', 'MANDER', 'PARIS', 'HARIS', Nan, 'PARIS', Nan])
  </code></pre>
  <p>It should generate match if the word appears separately in the string (and within that, upto 1 char substitution allowed)</p>
  <p>For eg - 'PARIS' can match against '<strong>PARIS</strong> HILTON', 'THE <strong>HARIS</strong> DOWNTOWN', but not against 'APARISIAN'.</p>
  <p>Similarly, 'XANDER' matches against 'NOVA <strong>XANDER</strong>' and 'SALA <strong>MANDER</strong>' (MANDER being 1 char diff from XANDER) , but does not generate match against 'ALEXANDERS'.</p>
  <p>As of now, we have written the logic for the same (shown below), although the match takes over 4 hrs to run.. Need to get this to under 30 mins.</p>
  <p>Current code -</p>
  <pre><code>tags_regex = ref_df['REF_NAMES'].tolist()
  tags_ptn_regex = '|'.join([f'\s+{tag}\s+|^{tag}\s+|\s+{tag}$' for tag in tags_regex])
  
  
  def search_it(partyname):
      m = regex.search(&quot;(&quot;+tags_ptn_regex+ &quot;)&quot;+&quot;{s&lt;=1:[A-Z]}&quot;,partyname):
      if m is not None:
          return m.group()
      else:
          return None
      
  df['MATCH'] = df['NAMES'].str.apply(search_it)
  </code></pre>
  <p>Also, will multiprocessing help with regex ? Many thanks in advance!</p>