Python pandas: create new column based on category values from another dataframe
<p>I have two dataframes: </p>

<ul>
<li><code>dfA</code>, which contains thousands of lines of temperature data. Each temperature value is linked to a <code>timeID</code> value (1, 2, 3, ..., n) measured from different objects, so that there are repeated time IDs</li>
<li><code>dfB</code> contains labels identifying each time ID. These labels are proper date/time (<code>date</code>) values</li>
</ul>

<p>Now, I would like to create a new column in <code>dfA</code>, which contains the correct <code>date</code>value corresponding to the right <code>timeID</code>. How can I achieve this?</p>

<p>Here are a few lines of the datasets I have, as an example:</p>

<pre><code>dfA = pd.DataFrame({'timeID': ['1', '2', '3','2','3','4'], 'temp': ['4.5', '5.1', '4.0','-2.3','3.9','-1.1']})
dfB = pd.DataFrame(pd.date_range('6/24/2013', periods=6, freq='10Min'))
seq = pd.Series(range(1, 7)).to_frame()
dfB = pd.concat([seq,dfB],axis=1)
dfB.columns = ['timeID','date']
dfB.set_index('timeID',inplace=True)
print(dfA)
print(dfB)
</code></pre>

<p>The output for <code>dfA</code> is:</p>

<pre><code>|    temp  timeID
+-----------------
| 0   4.5      1
| 1   5.1      2
| 2   4.0      3
| 3  -2.3      2
| 4   3.9      3
| 5  -1.1      4
</code></pre>

<p>The output for <code>dfB</code>is:</p>

<pre><code>|                      date
| timeID                    
+----------------------------
| 1      2013-06-24 00:00:00
| 2      2013-06-24 00:10:00
| 3      2013-06-24 00:20:00
| 4      2013-06-24 00:30:00
| 5      2013-06-24 00:40:00
| 6      2013-06-24 00:50:00
</code></pre>