Use a set
to create the sequence of unique elements.
Do some clean-up on df
to get the strings in lower case and split:
df['text'].str.lower().str.split()
Out[43]:
0 [my, nickname, is, ft.jgt]
1 [someone, is, going, to, my, place]
Each list in this column can be passed to set.update
function to get unique values. Use apply
to do so:
results = set()
df['text'].str.lower().str.split().apply(results.update)
print(results)
set(['someone', 'ft.jgt', 'my', 'is', 'to', 'going', 'place', 'nickname'])
Or use with Counter()
from comments:
from collections import Counter
results = Counter()
df['text'].str.lower().str.split().apply(results.update)
print(results)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…