searching a string pattern from a Data-frame column in pandas
<p>Continuing my last question in stack <a href="https://stackoverflow.com/questions/36740680/searching-matching-string-pattern-from-dataframe-column-in-python-pandas">searching matching string pattern from dataframe column in python pandas</a></p>

<p>Suppose i have a dataframe </p>

<pre><code> name         genre
 satya      |ACTION|DRAMA|IC|
 satya      |COMEDY|DRAMA|SOCIAL|MUSIC|
 abc        |DRAMA|ACTION|BIOPIC|
 xyz        |ACTION||ROMANCE|DARMA|
 def        |ACTION|SPORT|COMEDY|IC|
 ghj        |IC|ACTIONDRAMA|NOACTION|
</code></pre>

<p>From the answer of my last question , i am able to search any one genre (ex IC) if independently exist in genre column and not as a part of any other genre string value (MUSIC or BIOPIC).</p>

<p>Now i want to find if ACTION And DRAMA both present in a genre column but not necessarily in particular order and as not part of string but individually.</p>

<p>So i need rows in output  row[1,3,4]</p>

<pre><code> name         genre
 satya      |ACTION|DRAMA|IC|   # both adjacently present
 #row 2 will not come           # as only DRAMA present not ACTION
 abc        |DRAMA|ACTION|BIOPIC|   ### both adjacently present in diff. order
 xyz        |ACTION||ROMANCE|DARMA|   ### both present not adjacent
 ##row  5 should not present as DRAMA is not here
 ## row 6 should not come as both are not present individually(but present as one string part)
</code></pre>

<p>I tried something like </p>

<pre><code> x = df[df['gen'].str.contains('\|ACTION\|DRAMA\|')]
 ### got only Row  1 (ACTION and DRAMA in adjacent and in order ACTION-&gt;DRAMA)
</code></pre>

<p>Please somebody suggest what can be followed/added here so that i can get what i need here.</p>