Intergrating 2 dataframes based on specific column values
<p>I am not sure if my question is correct or not, but I will try to explain it clearly here.</p>

<p>I have two dataframes, df and df2.</p>

<p>df consist of country names and their short names</p>

<pre><code> Country    |    Shortname
 England           ENG
 United States     USA
 China             CN
 Thailand          TH
</code></pre>

<p>df2 consists of multiple country names including duplicates:</p>

<pre><code>Country
England
England
China
China
China
Thailand
England
</code></pre>

<p>I want to integrate Shortname from df in to a new column Shortname in df2 by comparing Country in both dataframes.
This is my desired result:</p>

<p>df2</p>

<pre><code>Country   |   Shortname
England         ENG
England         ENG
China           CN
China           CN
China           CN
Thailand        TH
England         ENG
</code></pre>

<p>Thank you very much.</p>

<p>Alternatively, consider <a href="http://pandas.pydata.org/pandas-docs/stable/merging.html" rel="nofollow">merge</a>:</p>

<pre><code>df2 = pd.merge(df2, df, on='Country')
</code></pre>

<p>Or join:</p>

<pre><code>df2 = df2.join(df, on='Country')
</code></pre>

python pandas dataframe