title: Python (Pandas) error 'the label [Algeria] is not in the [index]'
body: <p>I do not understand why this works </p>
  
  <pre><code>df[(df['Gold']&gt;0) &amp; (df['Gold.1']&gt;0)].loc[((df['Gold'] - df['Gold.1'])/(df['Gold'])).abs().idxmax()]
  </code></pre>
  
  <p>but when I divide by <code>(df['Gold'] + df['Gold.1'] + df['Gold.2'])</code>
  it stops working giving me error that you can find below.</p>
  
  <p>Interestingly, the following line works</p>
  
  <pre><code>df.loc[((df['Gold'] - df['Gold.1'])/(df['Gold'] + df['Gold.1'] + df['Gold.2'])).abs().idxmax()]
  </code></pre>
  
  <p>I do not understand what is happening since I just started to learn Python and Pandas. I need to understand the reason why this happens and how to fix it.</p>
  
  <p>ERROR</p>
  
  <blockquote>
    <p>KeyError: 'the label [Algeria] is not in the [index]'</p>
  </blockquote>
  
  <p>DataFrame snap
  <a href="https://i.stack.imgur.com/921vR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/921vR.png" alt="enter image description here"></a></p>