title: Pandas conditionally select column values based on data from other dataframe
body: <p>Is there a way that I can create a new column in a dataframe by selecting values from different columns from another dataframe based on some conditions in the first dataframe?</p>
  
  <p>My data sets are like this:</p>
  
  <pre><code>df1 = pd.DataFrame(
      [['USA', 1992],
      ['China', 1993],
      ['Japan', 1994]],
      columns = ['Country', 'year'])
  scores = pd.DataFrame(
      [['USA', 20, 30, 40],
      ['China', 5, 15, 30],
      ['Japan', 30, 50, 40],
      ['Korea', 10, 15, 20],
      ['France', 10, 12, 15]],
      columns = ['Country', 1992, 1993, 1994])
  </code></pre>
  
  <p>And my desired dataset would be:</p>
  
  <pre><code>df = pd.DataFrame(
      [['USA', 1992, 20]
      ['China', 1993, 15]
      ['Japan', 1994, 40]],
      columns = ['Country', 'year', 'score'])
  </code></pre>
  
  <p>I have tried using apply with a lambda function but it gives me a </p>
  
  <pre><code>KeyError: ('Country', u'occurred at index Country')
  </code></pre>
  
  <p>the line that I have tried is:</p>
  
  <pre><code>df1['score'] = df.apply(lambda x: scores[scores['Country'] == x['Country']][x['year']][1])
  </code></pre>
  
  <p>Thank you in advance!</p>