How to Analyze Word Frequencies with TextBlob in Python

This quick tutorial shows how to analyze word frequencies in text using TextBlob. For a complete introduction to text analysis in Python, see our Getting Started with TextBlob in Python guide.

The Problem

Sentiment scores and part-of-speech tags give you structured insights about text, but they don’t show you which specific words appear most. Knowing which terms show up repeatedly across a dataset helps you spot recurring themes, surface common complaints in reviews, and understand the vocabulary driving your data before moving into deeper analysis. It’s also a practical first step before building word cloud or term frequency visualizations.

The Solution

TextBlob’s .words attribute returns a tokenized WordList from any text. Combining it with Python’s built-in Counter class lets you build a frequency table across multiple texts with a few lines of code.

The example below processes four product reviews and prints the most common terms:

 
from textblob import TextBlob
from collections import Counter

reviews = [
    "Great product, fast shipping. Really fast delivery.",
    "Product quality is great but delivery was slow.",
    "Fast delivery and great packaging. Love this product.",
    "Slow shipping ruined the experience. Product was fine."
]

all_words = []
for review in reviews:
    all_words.extend(TextBlob(review).words.lower())

counts = Counter(all_words)
for word, freq in counts.most_common(8):
    print(f"{freq}x  {word}")

Output:

 
4x  product
3x  great
3x  fast
3x  delivery
2x  shipping
2x  was
2x  slow
1x  really

Calling .lower() on the WordList normalizes case before counting, so “Fast” and “fast” register as one token. The .most_common(n) method returns the top n terms ranked by count. You can also pass the Counter directly to pd.DataFrame.from_dict() to turn the results into a sortable table using pandas.

A Little Something Extra

Raw frequency counts pull in function words like “was,” “the,” and “and” that appear often but don’t reveal much about content. Filter them out using NLTK’s stop word list before counting. The stopwords corpus isn’t included in TextBlob’s default download, so fetch it directly before use:

 
import nltk
from nltk.corpus import stopwords

nltk.download("stopwords", quiet=True)

stop_words = set(stopwords.words("english"))
filtered = [w for w in all_words if w not in stop_words]
counts = Counter(filtered)
for word, freq in counts.most_common(8):
    print(f"{freq}x  {word}")

Output:

 
4x  product
3x  great
3x  fast
3x  delivery
2x  shipping
2x  slow
1x  really
1x  quality

The quiet=True argument suppresses the download confirmation message so your output stays clean. After the first run, NLTK loads the corpus from the local cache, so there’s no repeated download. The filtered list drops words like “was” and “the” and surfaces content terms like “great,” “fast,” and “shipping” — the vocabulary that actually reflects what reviewers are saying.

Conclusion

Word frequency analysis surfaces the most common terms in your text data with minimal setup. Add stop word filtering to shift the focus from filler words to the vocabulary that actually carries meaning.

Leave a Reply

Your email address will not be published. Required fields are marked *