title: Pandas OR statement ending in series contains
body: <p>I have a DataFrame <code>df</code> that has columns <code>type</code> and <code>subtype</code> and about 100k rows, I'm trying to classify what kind of data <code>df</code> contains by checking <code>type</code> / <code>subtype</code> combinations. While <code>df</code> can contain many different combinations there are particular combinations that only appear in certain data types. To check if my objects contains any of these combinations I'm currently doing:</p>
  
  <pre><code>typeA = ((df.type == 0) &amp; ((df.subtype == 2) | (df.subtype == 3) | 
           (df.subtype == 5) | (df.subtype == 6))) | 
           ((df.type == 5) &amp; ((df.subtype == 3) | (df.subtype == 4) | (df.subtype == 7) | 
           (df.subtype ==  8)))
  A = typeA.sum()
  </code></pre>
  
  <p>Where typeA is a long Series of Falses that might have some Trues, if A > 0 then I know it contained a True. The problem with this scheme is that if the first row of the df produces a True it still has to check everything else. Checking the whole DataFrame is faster then using a for loop with a break, but I'm wondering if there is a better way to do it.</p>
  
  <p>Thanks for any suggestions.</p>