title: How to compare a value in one dataframe to a column in another using fuzzywuzzy ratio
body: <p>I have a dataframe <code>df_sample</code> with 10 parsed addresses and am comparing it to another dataframe with hundreds of thousands of parsed address records <code>df</code>. Both <code>df_sample</code> and <code>df</code> share the exact same structure:</p>
  
  <pre><code>zip_code     city        state     street_number    street_name   unit_number   country
   12345    FAKEVILLE     FLORIDA          123           FAKE ST        NaN          US
  </code></pre>
  
  <p>What I want to do is match a single row in <code>df_sample</code> against every row in <code>df</code>, starting with <code>state</code> and take only the rows where the <code>fuzzy.ratio(df['state'], df_sample['state']) &gt; 0.9</code> into a new dataframe. Once this new, smaller dataframe is created from those matches, I would continue to do this for <code>city</code>, <code>zip_code</code>, etc. Something like:</p>
  
  <p><code>df_match = df[fuzzy.ratio(df_sample['state'], df['state']) &gt; 0.9]</code></p>
  
  <p>except that doesn't work.</p>
  
  <p>My goal is to narrow down the number of matches each time I use a harder search criterion, and eventually end up with a dataframe with as few matches as possible based on narrowing it down by each column individually. But I am unsure as to how to do this for any single record.</p>