title: How can I avoid overwriting in for-loops in Spyder (Python)?
body: <p>I have two Excel sheets. In each sheet I have a column with ID numbers and a column with results. If the ID numbers are identical from these two sheets, I want to add the results of those ID numbers to the first sheet into a new column called <code>new_Resultat2</code>. This is basically what my code is doing, but it always overwrites the value from the loop before. How can I avoid this?</p>
  <p>df1 looks like this:
  <a href="https://i.stack.imgur.com/ws7hM.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>and df2 like this:
  <a href="https://i.stack.imgur.com/vTCQM.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>This is my current code:</p>
  <pre class="lang-py prettyprint-override"><code>for i in df2['ID2']:
  
      for j in df1['ID1']:
          if j == i:
              # print(df2.Resultat2[df2.ID2 == i]) 
              df1['new_Resultat2'] = df2.Resultat2[df2.ID2 == i]
              print(df1['new_Resultat2'])
  </code></pre>