title: Detecting rapid increase in time series
body: <p>I have a time series and I would like to detect when the values are increasing rapidly increasing and pinpoint (color perhaps) the timeframe of the increase. For example in the following plot I would like to pinpoint the spikes for a specific time window in x-axis (for example 2018-05-22)</p>
  
  <p><a href="https://i.stack.imgur.com/K6Mqk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K6Mqk.jpg" alt="enter image description here"></a></p>
  
  <p>I am able to find the 20% maximum values but that does not help me. I want to focus on the rapid increases instead.</p>
  
  <pre><code>d = pd.Series(df['TS'].values[1:] - df['TS].values[:-1], index=df['TS'].index[:-1]).abs()
  threshold = 0.8
  m = d.max()
  print(d &gt; m * threshold)
  </code></pre>
  
  <p>For example, ruptures is doing something similar visually. There is an example with random data along the plot it produces:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import ruptures as rpt
  
  # generate signal
  n_samples, dim, sigma = 1000, 3, 4
  n_bkps = 4  # number of breakpoints
  #signal, bkps = rpt.pw_constant(n_samples, dim, n_bkps, noise_std=sigma)
  
  
  # detection
  algo = rpt.Pelt(model="rbf").fit(signal)
  result = algo.predict(pen=10)
  
  # display
  rpt.display(signal, bkps, result)
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/SCija.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SCija.jpg" alt="enter image description here"></a></p>