I have the code below which works to update a dataframe column 'flag' to yes or no based on a rolling window calculation of column 'A' (rolling window value value in 'A' should have a min >100 and max <200 to get yes value, otherwise value is no:
df['flag'] = np.where(
((df['A'].rolling(60).apply(lambda s: s.min()))> 50) &
((df['A'].rolling(60).apply(lambda s: s.max()))< 100)
,'yes', 'no')
Now I just need to change it so if condition is not met it does not update the df['flag'] value, instead of writing 'no'. Or maybe there is a whole different method to accomplish the same thing?
df.loc[m, 'flag'] = 'yes'for this (wheremis your mask).