df = pd.DataFrame([3, 2, 3, 2, 1], index=pd.DatetimeIndex(start=
    '2014-05-01 01:00:00', periods=5, freq='S'), columns=['output'])

def f(s):
    s = s[s & (s.index > s.name)]
if s.empty:
    return np.nan
else:
    return (s.index[0] - s.name).total_seconds()
df['secondsuntildecrease'] = df['output'].apply(lambda x: df['output'] < x
    ).apply(f, axis=1)
df
Python pandas calculate time until value in a column is greater than it is in current period