title: Assigning column of first data frame to the second one, if data frames have different size
body: <p>Suppose I have 2 data frames:</p>
  
  <pre><code>df1 = pd.DataFrame(np.arange(0,301),columns = ['id'])
  df2 = pd.DataFrame(np.arange(200,387),columns = ['id'])
  
  df1['2'] = np.random.randint(0,2,301)
  df2['2'] = np.random.randint(0,2,187)
  </code></pre>
  
  <p>Then I match id's from second data frame to first and create third df:</p>
  
  <pre><code>temp = df2.loc[df2['id'].isin(df1['id'])]
  </code></pre>
  
  <p>Then I calculate some value:</p>
  
  <pre><code>def values_14(row):
      if row['2'] == 1:
          return 1
      else:
          return 0
  
  
  temp['val'] = temp.apply(lambda row: values_14(row),axis = 1)
  </code></pre>
  
  <p>My question is: how can I assign values from the column <code>val</code> of data frame <code>temp</code> to the first data frame(if <code>id</code> in first data frame didn't match to the <code>id</code> of <code>temp</code>, then assign NA) in <strong>general</strong>? By in general I mean the situation, when <code>id</code> column, for example, are names and they are not sorted like a numbers. How can I do it in pandas?</p>