preV = data['x'].shift(1)
nexT = data['x'].shift(-1)
data['x'] = data['x'].where((data['x'] > 0) | (preV <= 0) | (nexT <= 0), (
    preV + nexT) / 2)
Data cleanup that requires iterating over pandas.DataFrame 3 rows at a time