title: Merge 'left', but override 'right' values where possible
body: <h3>Objective</h3>
  
  <p>I've reviewed <a href="https://pandas-docs.github.io/pandas-docs-travis/user_guide/merging.html" rel="nofollow noreferrer">pandas documentation on merge</a> but have a question on overriding values efficiently in a 'left' merge. I can do this simply for one pair of values (as seen <a href="https://stackoverflow.com/questions/35380010/python-pandas-replacing-values-in-one-df-by-same-index-values-from-another-df">here</a>), but it becomes cluttered when trying to do multiple pairs.</p>
  
  <h3>Setup</h3>
  
  <p>If I take the following dataframes:</p>
  
  <pre><code>a = pd.DataFrame({
     'id': [0,1,2,3,4,5,6,7,8,9],
      'val': [100,100,100,100,100,100,100,100,100,100]
  })
  
  b = pd.DataFrame({
      'id':[0,2,7],
      'val': [500, 500, 500]
  })
  </code></pre>
  
  <p>I can merge them:</p>
  
  <pre><code>df = a.merge(b, on=['id'], how='left', suffixes=('','_y'))
  </code></pre>
  
  <p>to get</p>
  
  <pre><code>   id  val  val_y
  0   0  100  500.0
  1   1  100    NaN
  2   2  100  500.0
  3   3  100    NaN
  4   4  100    NaN
  5   5  100    NaN
  6   6  100    NaN
  7   7  100  500.0
  8   8  100    NaN
  9   9  100    NaN
  </code></pre>
  
  <p>I want to keep left values where no right value exists, but where possible overwrite with the right values.</p>
  
  <p>My <strong>desired outcome</strong> is:</p>
  
  <pre><code>   id    val
  0   0  500.0
  1   1  100.0
  2   2  500.0
  3   3  100.0
  4   4  100.0
  5   5  100.0
  6   6  100.0
  7   7  500.0
  8   8  100.0
  9   9  100.0
  </code></pre>
  
  <h3>My Attempt</h3>
  
  <p>I know I can accomplish this with a few lines of code:</p>
  
  <pre><code>df.loc[df.val_y.notnull(), 'val'] = df[df.val_y.notnull()].val_y
  df = df.drop(['val_y'], axis = 1)
  </code></pre>
  
  <p>Or I can use the <a href="https://stackoverflow.com/questions/35380010/python-pandas-replacing-values-in-one-df-by-same-index-values-from-another-df">logic from this question</a>.</p>
  
  <p>But this becomes cluttered when there are multiple column pairings where I want to apply this logic. </p>
  
  <p>For example, using <code>a</code> and <code>b</code> below:</p>
  
  <pre><code>a = pd.DataFrame({
     'id': [0,1,2,3,4,5,6,7,8,9],
      'val': [100,100,100,100,100,100,100,100,100,100],
      'val_2':[200, 200, 200, 200, 200, 200, 200, 200, 200, 200]
  })
  b = pd.DataFrame({
      'id':[0,2,7],
      'val': [500, 500, 500],
      'val_2': [500,500,500]
  })
  </code></pre>
  
  <p>Is there a quicker, cleaner way to get my desired outcome?</p>