Hi I have a list and a pandas dataframe whose elements are lists as well. I want to find out if any one of elements of pandas column list are present in the other list and create one column with 1 if found and 0 if not found and another column with found elements as string separated by ,
. I found a similar question but couldn`t understand how could I use it for the case here. Check if one or more elements of a list are present in Pandas column. Thank you very much! :)
letters = ['a', 'b', 'c', 'f', 'j']
df_temp = pd.DataFrame({'letters_list' : [['a','b','c'], [ 'd','e','f'], ['g','h','i'], ['j','h','i']]})
How can I create a new column found
which is 1 if any letter in list letters
is found in letters_list
, and another column letters_found
which outputs letters matched in the list as string separated by ,
? It would like like following.