# Detect a pattern in time series data

I have the following time serie data and I need to detect the following pattern: - a 1st spike above a given value - a 2nd spike close to the given value

What defines "a spike" is that its value is x% above the surrounding spikes.

I would like to use python (numpy and pandas modules) to detect these.

As a background, the goal is to trigger an action when the second spike is detected (outlined in red in the attached image).

scipy.signal's finds_peaks should have most of what you need.
With the height argument you can set a minimum threshold to get the first peak.
With the prominence argument you should be able to approximate the second peak. This requires peak_prominences.