s = pd.Series([10.0247,10.0470, 10.0647,10.0761,15.0800,10.0761,10.0647,10.0470,10.0247,10.0,9.9753,9.9530,9.9353,9.9239,18.92,9.9239,9.9353,9.9530,9.9753,10.0])df = pd.DataFrame(s)df.columns=['value']df['val_1'] = df['value'].diff()df['val_2'] = df['val_1'].shift(-1)df['val'] = df.apply(lambda row: my_min(row['val_1'], row['val_2']), axis=1)