title: Filtering a dataframe using Lambda in Python
body: <p>I have two data frames in python: df and list:</p>
  
  <pre><code>data1 = [[0, ("a","b")], [1, ("d","e")], [2, ("a","e")],[3,("f", "g")],[4,("c","h")]]
  df = pd.DataFrame(data1, columns = ['Row', 'Letters'])
  data2 = [[0,"a"],[1,"b"],[2,"c"]]
  list = pd.DataFrame(data2, columns = ['Row', 'Letters'])
  </code></pre>
  
  <p>I now want to filter down df for only rows such that <em>any</em> item in df['Letters'] is found in list['Letters']</p>
  
  <p>The Any function works fine for individual rows:</p>
  
  <pre><code>any(item in df["Letters"][1] for item in list['Letters'])
  any(item in df["Letters"][2] for item in list['Letters'])
  </code></pre>
  
  <p>correctly returns False and True, respectively.</p>
  
  <p>Now how do I filter down the entire dataframe?</p>
  
  <p>I tried the following code:</p>
  
  <pre><code>new_df = df[df.apply(lambda x : any(item in x["Letters"] for item in list), axis=1)]
  </code></pre>
  
  <p>which returns an empty dataframe when I want to return only rows 0, 2 and 4.</p>
  
  <p>Any help would be appreciated.</p>