I have a column of string(sentence) and a column of comma separated list of strings as follows:
df = pd.DataFrame({ 'text':['the weather is nice though', 'How are you today','the beautiful girl and the nice boy'], 'pos':[['DET', 'NOUN', 'VERB','ADJ', 'ADV'],['QUA', 'VERB', 'PRON', 'ADV'], ['DET', 'ADJ', 'NOUN','CON','DET', 'ADJ', 'NOUN' ]]}) and I would like to somehow compare the columns, and create a third column where if the 'pos' column contains the value 'ADJ', I would find its corresponding value in the 'text' column (in this case in the first row I have 'nice') and return its index as well in a form of a dictionary . so this is how the third column should look like;
third_column: 1 {'nice' : 3} 2 {} 3 {'beautiful':1, 'nice':6} so far I have tried the following:
df['Third_column']= ' ' df['liststring'] = [' '.join(map(str, l)) for l in df['pos']] df.loc[df['liststring'].str.contains('ADJ'),'text'] but do not know how to proceed to get the exact word and the index