title: Replace an Entire Row in Pandas with its Predecessor (Python)
body: <p>I have the following data:</p>
  
  <pre><code>x                         y   event
  20150622.172807.769815   382
  20150622.172807.769818   327
  20150622.172807.769825   399  event
  20150622.172807.769836   342
  ...
  20150622.172807.769899   559
  </code></pre>
  
  <p>In the column "event", if there is an event, I want to replace the entire row with the value of the previous row, like this:</p>
  
  <pre><code>x                         y   event
  20150622.172807.769815   382
  20150622.172807.769818   327
  20150622.172807.769818   327
  20150622.172807.769836   342
  ...
  20150622.172807.769899   559
  </code></pre>
  
  <p>My code is:</p>
  
  <pre><code>for i, element in enumerate(df['event']):
      if element == 'event':
          df.ix[i,'event']= df['event'][i-1]
      else:
          df.ix[i,'event']= df['event'][i]
  </code></pre>
  
  <p>However, it keeps telling me the following error:</p>
  
  <pre><code>KeyError: -1
  </code></pre>
  
  <p>What is wrong with the code?
  Thank you all!!!</p>