title: Find the closest index of the value before and after the specified index
body: <p>I have a dataframe - record of the stimulation</p>
  <p>There i have a column where laser impulses are marked by '1's
  And a column where the ECG peaks marked by '1's</p>
  <p><img src="https://i.stack.imgur.com/EjQHz.png" alt="enter image description here" /></p>
  <p>I am trying to come up with an efficient method to find two ecg peaks closest to the laser peak - one before and one after the laser peak</p>
  <p><img src="https://i.stack.imgur.com/pNycs.png" alt="enter image description here" /></p>
  <p>For me the simplest way seems to be  a 'while' cycle, but maybe there are some pandas functions that can make it more efficiently?</p>