title: Updating dataframe column with values from a different dataframe
body: <p>I have two dataframes and I want to update one of the dataframe based on matching id's from the second one, but only on 1 column. Both dataframes contain other columns that I am not concerned about and should not be updated.</p>
  
  <p>For example:</p>
  
  <p>df1</p>
  
  <pre><code>id    name  ...
  123   city a
  456   city b
  789   city c
  789   city c
  456   city b
  123   city a
  .
  .
  .
  </code></pre>
  
  <p>so on and so forth</p>
  
  <p>df2</p>
  
  <pre><code>id    name  ...
  123   City A
  456   City B
  789   City C
  .
  .
  .
  </code></pre>
  
  <p>So the resulting <code>df_new</code> should be:</p>
  
  <pre><code>id    name  ...
  123   City A
  456   City B
  789   City C
  789   City C
  456   City B
  123   City A
  .
  .
  .
  </code></pre>
  
  <p>Right now what I'm doing is:</p>
  
  <pre><code>df2 = df2.set_index('id')
  df1 = df.set_index('id')
  df1.update(df2)
  df1.reset_index(inplace=True)
  df2.reset_index(inplace=True)
  </code></pre>
  
  <p>So I tried to write this into a function like this:</p>
  
  <pre><code>def replace_names(df1, df2, 'id'):
      df2 = df2.set_index('id')
      df1 = df.set_index('id')
      df1.update(df2)
      df1.reset_index(inplace=True)
      df2.reset_index(inplace=True)
      return df
  </code></pre>
  
  <p>However, this seems to return a dataframe of <code>NoneType</code> when used as a function. </p>
  
  <p>I would also like to change this to a method where instead of reindexing two dataframes and resetting them, if there is a way to pick an <code>id</code> and <code>names</code> column on two dataframes as variables and just apply a function like this only on those two columns, without updating or changing anything else in the rest of the columns on either dataframes.</p>
  
  <p>Any help would be appreciated!</p>