Compare Pandas dataframes and add column
<p>I have two dataframe as below </p>

<pre><code>df1     df2 
A       A   C
A1      A1  C1
A2      A2  C2
A3      A3  C3
A1      A4  C4
A2          
A3          
A4          
</code></pre>

<p>The values of column 'A' are defined in  df2 in column 'C'.
I want to add a new column to df1 with column B with its value from df2 column 'C'</p>

<p>The final df1 should look like this </p>

<pre><code>df1
A   B
A1  C1
A2  C2
A3  C3
A1  C1
A2  C2
A3  C3
A4  C4
</code></pre>

<p>I can loop over df2 and add the value to df1 but its time consuming as the data is huge. </p>

<pre><code>    for index, row in df2.iterrows():
           df1.loc[df1.A.isin([row['A']]), 'B']= row['C']
</code></pre>

<p>Can someone help me to understand how can I solve this without looping over df2.</p>

<p>Thanks</p>