title: How to create a new column in Pandas DataFrame based on a combination 1 and many columns
body: <p>I have a data set that looks like this: </p>
  
  <pre><code>   Cond  Column_A  Column_B  Column_C  Cumulative_Count
  0     1     -0.60     -0.12     -0.17                 1
  1     0      0.30      0.70      0.98                 0
  2     1     -0.45     -0.71     -0.99                 2
  3     1      0.60      0.12      0.17                 1
  4     0      0.20      0.80      0.60                 0
  5     1      0.70      0.14      0.20                 1
  </code></pre>
  
  <p>I would like to create a column Cumulative_Count that counts occurrence of an event based on multiple conditions such as: </p>
  
  <p>1) If Cond=1 and (Column_A&lt;0.5 or Column B>0.5) then Cumulative_Count=Cumulative_Count+1</p>
  
  <p>2) If Cond=1 and (Column_B&lt;0.5 or Column B>0.5) then Cumulative_Count=Cumulative_Count+1</p>
  
  <p>3) If Cond=1 and (Column_C&lt;0.5 or Column C>0.5) then Cumulative_Count=Cumulative_Count+1</p>
  
  <p>I would like to use NumPy arrays to perform it because my dataset is very large.  I tried using below code, it is not throwing error, but the result is not correct. And, I need to use it for all columns if possible because I have 50+ columns.  </p>
  
  <pre><code>df['Cum_Count']=0
  df['Cum_Count']=np.where((df['Cond']&gt;0 &amp; ((df['Column_A']&lt;-0.5) | (df['Column_A']&gt;0.5))), df['Cum_Count']+1, df['Cum_Count'])
  </code></pre>