<p>您可以使用<a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.map.html" rel="nofollow noreferrer">^{<cd2>}</a>创建新的<code>Series</code>,然后使用<a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.fillna.html" rel="nofollow noreferrer">^{<cd3>}</a>或<a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.combine_first.html" rel="nofollow noreferrer">^{<cd4>}</a>替换缺少的值:</p>
<pre><code>s1 = ip['instrument'].map(cusipmap.set_index('CUSIP')['ID'])
s2 = ip['instrument'].map(isinmap.set_index('ISIN')['ID'])
ip['Id'] = s1.fillna(s2)
print (ip)
instrument CUSIP ISIN Id
0 a US1 NaN a1
1 b NaN EU1 b1
2 c US2 NaN c1
</code></pre>
<p>使用<code>merge</code>的解决方案:</p>
<pre><code>s1 = ip.merge(cusipmap.rename(columns={'CUSIP':'instrument'}),on='instrument',how='left')['ID']
s2 = ip.merge(isinmap.rename(columns={'ISIN':'instrument'}),on='instrument',how='left')['ID']
ip['Id'] = s1.combine_first(s2)
print (ip)
instrument CUSIP ISIN Id
0 a US1 NaN a1
1 b NaN EU1 b1
2 c US2 NaN c1
</code></pre>