x = {"INPUT" : ['A','B','B','B','B','B','A','B','B','C','B','B','C','B','B','A','B','C']}df = pd.DataFrame(x)df
Condition for calculation of “OUTPUT” column
condition(1)if INPUT value A then OUTPUT 1
condition(2)if INPUT value C then OUTPUT -1
condition(3.i)if INPUT value B and B present after C then OUTPUT -1
condition(3.ii.a)if INPUT value B and B present after A and upto 3 consecutive INPUT value of B then OUTPUT 1
condition(3.ii.b)if INPUT value B and B present after A and after 3 consecutive INPUT value of B then OUTPUT -1