How can I add the count of string present in target column.
data = [{'target': ['Aging','Brain', 'Neurons', 'Genetics']},
{'target': ['Dementia', 'Genetics']},
{'target': ['Brain','Dementia', 'Genetics']}]
df = pd.DataFrame(data)
Dataframe
target
0 [Aging, Brain, Neurons, Genetics]
1 [Dementia, Genetics]
2 [Brain, Dementia, Genetics]
Unique labels
target = []
for sublist in df['target'].values:
tmp_list = [x.strip() for x in sublist]
target.extend(tmp_list)
target = list(set(target))
# ['Brain', 'Neurons', 'Aging', 'Genetics', 'Dementia']
