get unique words from pandas dataframe 1

get unique words from pandas dataframe

results = set()
df['text'].str.lower().str.split().apply(results.update)

$ set(['someone', 'ft.jgt', 'my', 'is', 'to', 'going', 'place', 'nickname'])

Here is what the above code is Doing:
1. We create an empty set called results.
2. We apply the .split() method to each row of the ‘text’ column.
3. We convert each word to lowercase.
4. We update the results set with the unique words from each row.
5. We print the results set.

Similar Posts