I have the following dataframe in pandas
target A B C
0 cat bridge cat brush
1 brush dog cat shoe
2 bridge cat shoe bridge
How do I test whether df.target
is in any of the columns ['A','B','C', etc.]
, where there are many columns to check?
I have tried merging A,B and C into a string to use df.abcstring.str.contains(df.target)
but this does not work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…