title: pandas fuzzy match on the same column but prevent matching against itself
body: <p>This is a common question but I have an extra condition: how do I remove matches based on a unique ID? Or, how to prevent matching against itself?</p>
  <p>Given a dataframe:</p>
  <pre><code>df = pd.DataFrame({'id':[1, 2, 3],
                     'name':['pizza','pizza toast', 'ramen']})
  </code></pre>
  <p><a href="https://i.stack.imgur.com/3vXZM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3vXZM.png" alt="enter image description here" /></a></p>
  <p>I used solutions like this one to create a multi-index dataframe:</p>
  <p><a href="https://stackoverflow.com/questions/54865890/fuzzy-match-strings-in-one-column-and-create-new-dataframe-using-fuzzywuzzy">Fuzzy match strings in one column and create new dataframe using fuzzywuzzy</a></p>
  <pre><code>df_copy = df.copy()
  
  compare = pd.MultiIndex.from_product([df['name'], df_copy['name']]).to_series()
  
  def metrics(tup):
      return pd.Series([fuzz.ratio(*tup),
                        fuzz.token_sort_ratio(*tup)],
                       ['ratio', 'token'])
  
  compare.apply(metrics)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/hM7nT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hM7nT.png" alt="enter image description here" /></a></p>
  <p>So that's great but how can I use the unique ID to prevent matching against itself?</p>
  <p>If there's a case of ID/name = 1/pizza and 10/pizza, obviously I want to keep those. But I need to remove the same ID in both indexes.</p>