Mapping data from other dataset. Python Pandas
<p>So i got 2 datasets, <code>df1</code> has the colour for all fruits and <code>df2</code> don't. How do I map the color values for <code>df2</code> based on the color data from <code>d1</code>, according to the fruit names? </p>

<pre><code>               df1                                  df2
Name               Color             Name              Color
Apple              Red               Orange            Na
Orange             Orange            Coconut           Na
Pear               Pear              Pear              Na
Pear               Pear              Strawberries      Na
Papaya             Papaya            Banana            Na
Watermelon         Watermelon        Papaya            Na
               "                  "                 "                 "
</code></pre>

<p>You can do this with <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html" rel="nofollow">merge</a>:</p>

<pre><code>df2 = df2.merge(df1, on="Name", how="left", suffixes=('_1','_2'))
</code></pre>

<p>if name is your index column you can just do a <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.join.html" rel="nofollow">join</a>:</p>

<pre><code>df2 = df2.join(df1[['color']])
</code></pre>

<p>For a more complete example you can look at the answer above/below that was kind enough to elaborate on my answer.</p>

python pandas merge mapping multiple-columns