I have the following dataframe
pd.DataFrame({'category': [1,2,1], 'names' : ['ab c', 's', 'dm ab aaa']})
category names
0 1 ab c
1 2 s
2 1 dm ab aaa
Really I need to find all unique tokens(separated by space) in names column, assign corresponding category and create new datafrane as you can see below:
pd.DataFrame({'category' : [1, 1,2,1,1,1], 'names' : ['ab', 'c', 's', 'dm', 'ab', 'aaa']})
category names
0 1 ab
1 1 c
2 2 s
3 1 dm
4 1 ab
5 1 aaa
Please help me and how to do it the best way...
question from:
https://stackoverflow.com/questions/66068405/tokenize-dataframe-column-and-create-new-dataframe-for-result 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…