For this table:
I would like to generate the 'desired_output' column. One way to achieve this maybe:
- All the True values from col_1 are transferred straight across to desired_output (red arrow)
- In desired_output, place a True value above any existing True value (green arrow)
Code I have tried:
df['desired_output']=df.col_1.apply(lambda x: True if x.shift()==True else False)
Thankyou