Python pandas: Find a value in another dataframe and replace it
<p>I have two dataframes df_l (with 3000 rows) and df_s(with 100 rows) :
df_l</p>

<pre><code>version|update_date
2.3.4| date1
3.4.5|date2
</code></pre>

<p>and df_s</p>

<pre><code>version|release_date
    2.3.4| date1
    3.4.5|date2
    3.3.3|date3
</code></pre>

<p>I want to check if a version in df_l is in df_s, then I want to update the values in df_l.update_date to df_s.release_date. Here is my code</p>

<pre><code>df_l.ix[df_l['version'].isin(df_s['version']),'update_date'] = df_s['release_date']
</code></pre>

<p>but the updated values in df_l.update_date are wrong I am guessing that the matching is not taking place correctly. Can anybody help?</p>

<p>IIUC you need <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.merge.html" rel="nofollow"><code>merge</code></a> with inner join <code>how='inner'</code> which is by default. Also you can omit <code>on</code> if in both <code>DataFrames</code> are only 2 columns and one of them is same in both:</p>

<pre><code>print (pd.merge(df_l, df_s))
  version update_date release_date
0   2.3.4       date1        date1
1   3.4.5       date2        date2
</code></pre>

python string pandas matching