title: Comparing column values within a row within a Pandas Dataframe
body: <p>I have a specific and a general problem I'm trying to solve.</p>
  
  <p><strong>Specific Problem:</strong>
  I want to create a new column in a data frame that gives a 1 if column C1 is 8 and all other values in the row are less than 8.How do I logically negate all of the other columns at the same time? Here is the code from my flawed attempt:</p>
  
  <pre><code>df["C1is_8"] = df.apply(lambda row:(row['C1']==8)&amp; ~(row['C1']&lt;8) ,axis=1).astype(int)
  </code></pre>
  
  <p>The code below produces the dataframe for the code above.</p>
  
  <pre><code>dict = { 'C1':[4,3,0,0,2,3,4,5,8,8,8,8],
           'C2':[8,3,3,7,6,5,3,5,6,8,8,8],
           'C3':[2,3,6,4,5,0,0,4,6,7,8,8],
           'C4':[8,5,4,4,4,3,2,1,4,2,6,8]
         }
  columns = ['C1','C2','C3','C4']
  Index = [1,2,3,4,5,6,7,8,9,10,11,12]
  df = pd.DataFrame(dict,index = Index,columns = columns)
  df = OGdf[::-1]
  df
  </code></pre>
  
  <p><strong>General Problem:</strong> How do I rewrite some version of the code above so that I can generalize it (i.e. row[ i ] ) so that it could apply to any column not just 'C1'?</p>