title: Python - Replace Dataframe in a Loop
body: <pre><code>tmp = pd.DataFrame({'Fruit' : ['Apple','Pear'],
                'Val' : [1,2],
                })
  
  tmp2 = pd.DataFrame({'Fruit' : ['Apple','Pear'],
                    'Val2' : [3,3],
                    })
  
  tomerge = pd.DataFrame({'Fruit' : ['Apple','Pear'],
                    'Colour' : ['Red','Green'],
                    })
  </code></pre>
  <p>I want to merge tmp and tmp2 with tomerge in a loop.</p>
  <pre><code>for i in [tmp,tmp2]:
      i =  pd.merge(i,tomerge,how='left', left_on='Fruit', right_on='Fruit')
  </code></pre>
  <p>How can I get tmp and tmp2 to be updated? tmp and tmp2 remain the same after running the loop.</p>
  <p>The loop above merges tmp2 and tomerge and calls the dataframe &quot;i&quot; instead of tmp2 again.</p>