filtering a pandas dataframe without removing rows,"df.where((df > df.shift(1)).values & (df.D == 1)[:, (None)], np.nan)"