title: How do I assign categories in a dataframe if they contain any element from another dataframe?
body: <p>I have two excel sheets. One contains summaries and the other contains categories with potential filter words. I need to assign categories to the first dataframe if any element matches in the second dataframe.</p>
  <p>I have attempted to expand the list in the second dataframe and map by matching the terms to any words in the first dataframe.</p>
  <h1>Data for the test.</h1>
  <pre><code>import pandas as pd
  
  data1 = {'Bucket':['basket', 'bushel', 'peck', 'box'], 'Summary':['This is a basket of red apples. They are sour.', 'We found a bushel of fruit. They are red and sweet.', 'There is a peck of pears that taste sweet. They are very green.', 'We have a box of plums. They are sour and have a great color.']}
  
  data2 = {'Category':['Fruit', 'Color'], 'Filters':['apple, pear, plum, grape', 'red, purple, green']}
  
  df1 = pd.DataFrame(data1)
  
  df2 = pd.DataFrame(data2)
  </code></pre>
  <hr />
  <pre><code>print(df1)
  
     Bucket                                            Summary
  0  basket     This is a basket of red apples. They are sour.
  1  bushel  We found a bushel of fruit. They are red and s...
  2    peck  There is a peck of pears that taste sweet. The...
  3     box  We have a box of plums. They are sour and have...
  </code></pre>
  <hr />
  <pre><code>print(df2)
  
    Category                   Filters
  0    Fruit  apple, pear, plum, grape
  1    Color        red, purple, green
  </code></pre>
  <hr />
  <h1>This line of script converts the Category column from the table to a list to use later.</h1>
  <pre><code>category_list =  df2['Category'].values
  
  category_list = list(set(category_list))
  </code></pre>
  <h1>Attempt to match the text.</h1>
  <pre><code>for item in category_list:
  
      item = df2.loc[df2['Category'] == item]
  
      filter_list =  item['Filters'].values
  
      filter_list = list(set(filter_list))
  
      df1 = df1 [df1 ['Summary'].isin(filter_list)] 
  </code></pre>
  <p>I want the first dataframe to have categories assigned to it separated by a comma.</p>
  <p>Result:</p>
  <pre><code>Bucket      Category                                            Summary
  0  basket  Fruit, Color     This is a basket of red apples. They are sour.
  1  bushel         Color  We found a bushel of fruit. They are red and s...
  2    peck  Fruit, Color  There is a peck of pears that taste sweet. The...
  3     box         Fruit  We have a box of plums. They are sour and have...
  </code></pre>
  <p>I hope this is clear. I have been banging my head against it for a week now.</p>
  <p>Thank you in advance</p>