I have list of sentences eg:
['i hate dogs', 'i like cats']
and a pandas dataframe with sentences and type as cols.
what I want to do is match these to the same sentences from my list to the pandas dataframe col ‘sentences’ and pull out the ‘Type’ col
so i would have another list of Types that all match up to the sentences in the first list.
sentence_list = ['i hate dogs', 'i like cats'] Type_list = ['neg','pos']
With df being your dataframe and ‘sentences’, ‘cols’ its columns, you can do the following:
Type_list = df.loc[df.sentences.isin(sentence_list), 'cols'].to_list()