title: Dynamically checking values in Dataframe
body: <p>Good Morning,</p>
  <p>I have a dataframe with 20+ columns. I'd like to add a new column 'Pattern Exists' such that it is set to 1 if a non-zero value exists in a subset of columns, otherwise it's set to 0. On any row, once a cell with non-zero value is found, we can set 'Pattern Exists' to 1 and move onto the next row.</p>
  <p>Is there a way to do this with list comprehension?</p>
  <pre><code>df_raw['Pattern Exists'] = 0 ## initiating the column to 0 ##
  
  for row in df_raw.index: ## iterating on dataframe rows ##
    for ptrn in pattern_accuracy['Pattern'].to_list(): ## checking values in the desired columns ##
      if df_raw[ptrn][row] != 0:
        df_raw['Pattern Exists'].loc[row] = 1
        break
  </code></pre>