I have a simple pandas data frame and list which is as fallows
import pandas as pd
frame = pd.DataFrame({'a' : ['the cat is blue', 'the sky is green', 'the dog is black']})
mylist =['cat blue', 'sky green', 'dog black']
how to find the match between this dataframe and list. I got the result when the list is like
mylist_1 = ['cat','sky','dog']
But when i try to solve with mylist the dataframe is not matching. Here is the piece of code which i used.
import pandas as pd
frame = pd.DataFrame({'a' : ['the cat is blue', 'the sky is green', 'the dog is black']})
print(frame)
mylist_1 =['cat', 'sky', 'dog']
import nltk
frame['Data'] = frame['a'].apply(lambda x : ([i for i in nltk.word_tokenize(x) if i in mylist_1]))
print(frame)
But how to match with the my_list with the dataframe. Please help me on this issue