I have a pandas dataframe with the three columns names A, B, C and want to add a fourth column with the following condition:
Note: prev X = previous entry of the column X
D = IF(A < prev D) and (B > prev D)
THEN A
ELSE prev D
Is there a way other than using for loop for accomplishing this using pandas or numpy?