pandas look for most used word code example
Example 1: most frequent word in a list python
words = [
'red', 'green', 'black', 'pink', 'black', 'white', 'black', 'eyes',
'white', 'black', 'orange', 'pink', 'pink', 'red', 'red', 'white', 'orange',
'white', "black", 'pink', 'green', 'green', 'pink', 'green', 'pink',
'white', 'orange', "orange", 'red'
]
from collections import Counter
word_counts = Counter(words)
top_four = word_counts.most_common(4)
print(top_four)
Example 2: how to get the top 100 frequent words on a python dataframe colummn
from collections import Counter
Counter(" ".join(df["text"]).split()).most_common(100)