title: Create forth column based on other columns (lagged) values
body: <pre><code>df = pd.DataFrame(np.random.randint(0,2,size=(5,3)), columns=list('ABC'))
  
  print (df)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/l56u6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l56u6.png" alt="A  B  C
  0  1  1  1
  1  0  0  1
  2  1  1  1
  3  1  1  0
  4  1  0  1" /></a></p>
  <p>I would like to create a forth column &quot;D&quot; which will take a value of 1 if:</p>
  <ul>
  <li>(at least) two column (A, B, C) have a value of 1 or</li>
  <li>the previous 2 periods had at least two columns with a value of 1.</li>
  </ul>
  <p>According to the example above all the rows would have <code>df['D']==1</code></p>