Find peaks and valleys in dataset with python