I want to search 'search_value' in 'Search in string' column for every row and return TRUE if any of the words separated by | in search_value are present in 'Search in string'
Thanks in advance
I want to search 'search_value' in 'Search in string' column for every row and return TRUE if any of the words separated by | in search_value are present in 'Search in string'
Thanks in advance
You could make good use of the keyword any and use apply(lambda x:) to your dataframe. It would result in this:
df['Flag'] = df.apply(lambda x: True if any(i in x['Search in string'].split() for i in x['Search_value'].split('|')) else False,axis=1)
This results in the expected output:
search_value ... Flag
0 civic|men|boy|furnishing|clothing|non durable|... ... True
1 environmental|cosmetic|beauty|perfume|apparel|... ... True