I have a data frame with 2 columns with strings comma-separated.
I'm trying to make speed-efficient solution to calculate 3-d column indicating if any of split strings from column A present in column B.
For example:
df = pd.DataFrame({'A':['apple', 'cucamber', 'tomato,mellon', 'tomato,potato'],
'B':['apple,banana', 'pineapple', 'tomato juice', 'cheese,tomato,onion']})
Result should be
A B C
apple apple,banana 1
cucamber pineapple 0
tomato,mellon tomato juice 0
tomato,potato cheese,tomato,onion 1
It could be > 1mln rows.
If it's crucial for speed, even without splitting second column is fine, just searchingsplitted strings from frist column in second.
A B C
apple apple,banana 1
cucamber pineapple 0
tomato,mellon tomato juice 1
tomato,potato cheese,tomato,onion 1
Appreciate any help.