title: Is it possible to search multiple columns for multiple values in pandas?
body: <p>I am a doctor looking at surgical activity in a DataFrame that has 450,000 records and 129 fields or columns. Each row describes a patient admission to hospital, and the columns describe the operation codes and diagnosis codes for the patient.</p>
  <pre class="lang-py prettyprint-override"><code>df.info()
  
  &lt;class 'pandas.core.frame.DataFrame'&gt;
  RangeIndex: 452883 entries, 0 to 452882
  Columns: 129 entries, fyear to opertn_24Type
  dtypes: float64(5), int64(14), object(110)
  memory usage: 445.7+ MB
  </code></pre>
  <p>There are 24 operation columns for each row. I want to search in the operation columns (1-24) for the codes for pituitary surgery <code>&quot;B041&quot; and &quot;B012&quot;</code>, to identify all patients who have had surgery for a pituitary tumor.</p>
  <p>I am a total python beginner and have tried using iloc to describe the range of columns (1-24) which appear starting at position 72 in the list of columns but couldn't get it to work.
  I am quite happy searching for individual values eg <code>&quot;B041&quot;</code> in a single column using
  <code>df[&quot;OPERTN_01&quot;] == &quot;B041&quot;</code>
  but would ideally like to search multiple columns (all the surgical columns 1-24) more efficiently.
  I tried searching the whole dataframe using</p>
  <p><code>test = df[df.isin([&quot;B041&quot;, &quot;B012&quot;])]</code></p>
  <p>but that just returns the entire dataframe with null values.</p>
  <p>So I have a few questions.</p>
  <ol>
  <li>How do I identify integer positions (iloc numbers) for columns in a large dataframe of 129 columns? I just listed them and counted them to get the first surgical column (&quot;OPERTN_01&quot;) at position 72 — there must be an easier way.</li>
  <li>What's the best way to slice a dataframe to select records with multiple values from multiple columns?</li>
  </ol>