df = pd.DataFrame(np.random.randint(0,2,size=(5,3)), columns=list('ABC'))
print (df)
I would like to create a forth column "D" which will take a value of 1 if:
- (at least) two column (A, B, C) have a value of 1 or
- the previous 2 periods had at least two columns with a value of 1.
According to the example above all the rows would have df['D']==1
