df['variation'] = df.OldCol / df.OldCol.shift()
df['gap'] = ~df.variation.between(0.9, 1.1)
df['NewCol'] = df.OldCol.where(df.gap).fillna(method='ffill')
How to write code in a vectorized way instead of using loops?