title: Why does this ID generating code make a KeyError: -1
body: <p>A problem in this part of my code causes KeyError: -1</p>
  
  <p>Do any of you know what might cause this?</p>
  
  <pre><code>for i in range(len(B130317)):
      if B130317['LON'][i] != B130317['LON'][i-1]:
          currentID += 1
      newID.append(currentID)
  </code></pre>