title: How to change values in one dataframe according to values in another dataframe?
body: <p>I have two dataframes, dataframe <code>A</code>, and its son dataframe <code>B</code>, since I need to change some values in B according to A using matching columns to input the comparison result in dataframe B.</p>
  
  <pre><code>A:
  name id 
  321  1
  18   1
  234  2
  12   2
  234  2
  
  ... ...
  B:
  name id  matching
  321  2
  14   2
  13   2
  234  1
  235  1
  </code></pre>
  
  <p>My searching rule is if a cell in column name of df <code>B</code> (eg. name = 321) has the same name as A, then check the id of the name (eg. id = 1 in B, id = 2 in A). </p>
  
  <p>After that, label all items who have the same id in B (eg. in B, name = 321,14,13 all have id =2) as matching = 1.</p>
  
  <p>I want the output like:</p>
  
  <pre><code>B:
  name id  matching
  321  2   1
  14   2   1
  13   2   1
  234  1   2
  235  7   2
  </code></pre>
  
  <p>My code takes a long time to work and still does not achieve my goal:</p>
  
  <pre><code>for i in range(0,len(A)):
      for j in range(0,len(B)):
  
          if A.name[i]== B.name[j]:
              B.matching[j] = A.id[i]
  </code></pre>
  
  <p>I want the output like:</p>
  
  <pre><code>OutB:
  name id  matching
  321  2   1
  14   2   1
  13   2   1
  234  1   2
  235  7   2
  </code></pre>
  
  <p>Is there any function or algorithm that could help me complete my goal?</p>