擅长:python、mysql、java
<p>我会将列表转换为字符串,然后使用<code>series.str.findall</code>返回匹配的类型代码:</p>
<pre><code>df['new_gen'] = df['gen'].astype(str).str.findall('|'.join(genre_code))
</code></pre>
<hr/>
<pre><code>print(df)
id tit gen new_gen
0 620 AAA [Romance, Satire, Fiction] []
1 843 BBB [Science Fiction, Novel] [Science Fiction]
2 986 CCC [Mystery, Novel] [Mystery]
</code></pre>