title: Is there code to group similar words contained in a column
body: <p>Is there code I can use to distinguish words that have similar string in Python? I want to group words, but then if I use the WHERE FUNCTION in the data frame for words like COFFEE and FEE, the words will be considered as the same, which I don't want.</p>
  
  <p>The data frame looks like this:</p>
  
  <pre><code>id        transaction           grouping
   1         ATM FEES               FEES
   2         McDonalds              MD
   3         COFFEE SHOP            FEES
   4         POS ZARA               ZARA
   5         TASTY COFFEE           FEES
   6         FREDDIES               OTHER
   7         FEES:Monthly           FEES
   8         WITHDRAWAL FEES ATM    FEES
   9         MONTE COFFEE SHOP      FEES
  </code></pre>
  
  <p>But I want the output to look like this:</p>
  
  <pre><code>id        transaction            grouping
   1         ATM FEES                FEES
   2         McDonalds               MD
   3         COFFEE SHOP             COFFEE
   4         POS ZARA                ZARA
   5         TASTY COFFEE            COFFEE
   6         FREDDIES                OTHER
   7         FEES:Monthly            FEES
   8         WITHDRAWAL FEES ATM     FEES
   9         MONTE COFFEE SHOP       COFFEE
  </code></pre>
  
  <p>This is the code I used:</p>
  
  <pre><code>tranx['grouping'] = pd.np.where(temp.str.contains("COFFEE"),"COFFEE",
                      pd.np.where(temp.str.contains("McDonalds"), "MD",
                      pd.np.where(temp.str.contains("FEE"), "FEE",
                      pd.np.where(temp.str.contains("ZARA"), "ZARA",OTHER))))
  </code></pre>
  
  <p>Is there other code I can use to be able to distinguish COFFEE and FEE so that they are not put under the same grouping?</p>