<h2>Python 2.7版</h2>
<pre><code>In [3]:import pandas as pd
df = pd.DataFrame(dict(A=['abc','abc','abc','xyz','xyz'],
B='abcdef','abcdefghi','notthisone','uvwxyz','orthisone']))
In [4]: df
Out[4]:
A B
0 abc abcdef
1 abc abcdefghi
2 abc notthisone
3 xyz uvwxyz
4 xyz orthisone
In [12]: df[df.B.str.contains(df.A) == True]
# just keep the B that contain A string
TypeError: 'Series' objects are mutable, thus they cannot be hashed
</code></pre>
<hr/>
<p>我正在努力做到这一点:</p>
<pre><code> A B
0 abc abcdef
1 abc abcdefghi
3 xyz uvwxyz
</code></pre>
<p>我试过结构包含声明,但是不行。非常感谢您的帮助。你知道吗</p>