assume "Tags" column as stores as below; How can I split into multiple columns or set into one list?
desired as " To be combined as List and filter-out duplication
"Tags"
['Saudi', 'law', 'Saudi Arabia', 'rules']
['Hindi', 'Tamil', 'imposition', 'cbse', 'neet', 'Tamil Nadu', 'India']
['Stephen', 'Hawkins', 'Tamil', 'predictions', 'future', 'science', 'scientist', 'top 5', 'five']
['Bigg Boss', 'Tamil', 'Kamal', 'big', 'boss']
['Mary', 'real', 'story', 'Tamil', 'history']
['football', 'Tamil', 'FIFA', '2018', 'world cup', 'MG', 'top', '10', 'ten']
['India', 'Tamil', 'poor', 'rich', 'money', 'MG', 'why', 'Indians']
CodePudding user response:
Try:
set(df["Tags"].sum())
Or:
list(dict.fromkeys(df["Tags"].sum()))
CodePudding user response:
If need split into multiple columns:
df = pd.DataFrame(df['Tags'].tolist())
For second:
L = list(set([y for x in df['Tags'] for y in x]))