擅长:python、mysql、java
<p>如果在新列中需要字符串,请尝试此操作</p>
<pre><code>df['Country Desc3']=df.apply(lambda x: ','.join(x.unique().tolist()), axis=1)
</code></pre>
<p>如果您需要新列中的列表</p>
^{pr2}$
<p>以防万一您需要<code>NaN</code>来表示没有匹配的行</p>
<pre><code>df['Country Desc3']=np.nan
df.loc[df['Country Desc1']==df['Country Desc2'],'Country Desc3']=df['Country Desc1']
</code></pre>