Python 2.7
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
I am trying for this:
A B
0 abc abcdef
1 abc abcdefghi
3 xyz uvwxyz
I have tried variations of the str.contains statement, but no go. Any help is much appreciated.