擅长:python、mysql、java
<p>我会使用几个numpy命令:</p>
<pre><code>df['new_col'] = 'others'
df.loc[np.logical_and(df.col_1=='EDU', np.in1d(df.col_2, ['facebook','google'])), 'new_col'] = df.loc[np.logical_and(df.col_1=='EDU', np.in1d(df.col_2, ['facebook','google'])), 'col_2']
df.loc[np.logical_and(df.col_1=='EDU', np.in1d(df.col_2, ['google_usa','tabula'])), 'new_col'] = 'gusa'
</code></pre>
<p>注:你的要求与你提出的结果不完全一致,我希望我已经正确地解释了这个要求。我的代码将输出:</p>
^{pr2}$