title: Filtering in pandas - how to apply a custom method (lambda)?
body: <p>I have a DataFrame where one of the columns contains an string which contains words  delimited by comma. </p>
  
  <pre><code>&gt;&gt;&gt; df['column1']
  # ....
  996                  str1, str2, str3
  997                  str4, str5, str7
  998                  str8, str9, str10
  # ...........
  </code></pre>
  
  <p>I need to treat the content of that column as an array of string so I can do this:</p>
  
  <pre><code> [
    # ..... 
    &amp; (df['column1'].isin('str2')) # should return the row #996
    # ....
   ]
  </code></pre>
  
  <p>I tried this but it hasn't panned out, of course:</p>
  
  <pre><code> [
    # ..... 
    &amp; (df['column1'].split(',').isin('str2'))
    # ....
   ]
  </code></pre>
  
  <p>How can I do that? Or rather how can I use a method (lambda) to modify the content of the column before filtering?</p>
  
  <p>UPDATE1:</p>
  
  <p>This is a part of my code:</p>
  
  <pre><code>for x in pd.read_csv.....
        df_item = x
  
        if filter1:
          df_item = df_item[(df_item['column1'] == filter1)]
  
        if filter2:
          df_item = df_item[(df_item['column2'].isin(subjects))]
  
        # .....
  </code></pre>
  
  <p>How can I apply <code>df['column2'].apply(lambda x: 'str2' in x.split(','))</code> to </p>
  
  <pre><code>  if filter2:
      df_item = df_item[(df_item['column2'].isin(subjects))]
  </code></pre>