擅长:python、mysql、java
<p>您可以调用列“A”上的<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.unique.html#pandas.Series.unique" rel="nofollow">^{<cd1>}</a>,然后与<code>|</code>联接,以使用<a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.contains.html#pandas.Series.str.contains" rel="nofollow">^{<cd3>}</a>创建匹配模式:</p>
<pre><code>In [15]:
df[df['B'].str.contains('|'.join(df['A'].unique()))]
Out[15]:
A B
0 abc abcdef
1 abc abcdefghi
3 xyz uvwxyz
</code></pre>