title: Filtering the comma separated values in multiple columns in a dataframe in pandas
body: <p>This is the example dataframe that I am working:</p>
  
  <pre><code>df:
  
  a      b     c
  a1  P1,P3  abc
  a2  P2,P4  def
  a3  P2     ghi   `
  </code></pre>
  
  <p>I want to apply filters on multiple columns in a dataframe which has comma separated values in them. </p>
  
  <p>Filter data is in the form of a <code>series</code> named as <code>df_filters</code> mentioned below:</p>
  
  <pre><code>df_filters:
  a    [a1]
  b    [P1, P4]`
  </code></pre>
  
  <p>The filter data contains dataframe <code>column name</code> as a <code>string</code> in first column and <code>filter values</code> as <code>list</code> in second column. </p>
  
  <p>Using the above <code>df_filters</code> filter the dataframe <code>df1</code> and get the following result:</p>
  
  <pre><code>Result1:
  a      b     c
  a1  P1,P3  abc
  a2  P2,P4  def  `
  </code></pre>
  
  <p>Conclusion: for column <code>a</code> in <code>df1</code> consider only those rows with value <code>a1</code> and for column <code>b</code> consider only those rows which contains values <code>P1</code> and <code>P4</code>. In column <code>b</code> row 1, <code>P1</code> and <code>P3</code> are two different values with comma separation. </p>
  
  <p>Is there anyway I can achieve the above <code>Result</code> for <code>df</code>?</p>
  
  <p>for reference to the similar scenario, kindly look into the following link:
  <a href="https://stackoverflow.com/questions/49444787/apply-a-list-of-filters-to-a-dataframe-coming-from-a-list-using-pandas">Apply a list of filters to a dataframe coming from a list using pandas</a></p>