TextBlob sentiment analysis gives each text two scores: polarity, from -1.0 (negative) to 1.0 (positive), and subjectivity, from 0.0 (fact) to 1.0 (opinion). It is a lexicon method: it looks up words in a list and averages their values. It needs no model download and no GPU, and it runs in three lines of Python. It works for English only, and it does not understand context.
This guide shows how to use it, how the score is calculated, what real output looks like and when to change to a different tool. For the other common Python options, see sentiment analysis in Python.
Quick start
pip install textblobfrom textblob import TextBlob
blob = TextBlob("The battery life is not great.")
print(blob.sentiment)
# Sentiment(polarity=-0.4, subjectivity=0.75)
print(blob.sentiment.polarity) # -0.4
print(blob.sentiment.subjectivity) # 0.75For a pandas column, apply the same call to each row:
df["polarity"] = df["text"].apply(lambda t: TextBlob(t).sentiment.polarity)Polarity and subjectivity
| Score | Range | Meaning |
|---|---|---|
| polarity | -1.0 to 1.0 | Negative to positive. 0.0 is neutral, or no known words. |
| subjectivity | 0.0 to 1.0 | 0.0 is objective (a fact). 1.0 is subjective (an opinion). |
TextBlob gives no label. Most projects add their own rule, for example: above 0.1 is positive, below -0.1 is negative, and the rest is neutral. Set the limits on a sample of your own text.
How TextBlob calculates the score
The default analyzer, PatternAnalyzer, comes from the Pattern library. It uses a lexicon of English words, mostly adjectives, in which each word has a polarity, a subjectivity and an intensity that were assigned by hand.
- Look up each word.
greathas polarity 0.8 and subjectivity 0.75. Words that are not in the lexicon are ignored. - Apply intensifiers.
verymultiplies the polarity of the next word.very greatgives 1.0, the maximum. - Apply negation.
notmultiplies the polarity by -0.5.not greatgives -0.4, not -0.8. - Average. The result is the mean of the values that were found.
You can see which words were used with sentiment_assessments:
TextBlob("The battery life is not very great.").sentiment_assessments
# Sentiment(polarity=-0.3077, subjectivity=0.5769,
# assessments=[(['not', 'very', 'great'], -0.3077, 0.5769, None)])Real outputs, and where they go wrong
These are unedited results from TextBlob 0.20.1, run on 11 November 2026.
| Text | Polarity | Subjectivity | Verdict |
|---|---|---|---|
| The battery life is great. | 0.8 | 0.75 | Correct |
| The battery life is not great. | -0.4 | 0.75 | Correct: "not" multiplies by -0.5 |
| This phone is very good! | 1.0 | 0.78 | Correct: "very" increases the score |
| The package arrived on Tuesday. | 0.0 | 0.0 | Correct: a fact |
| The update bricked my phone. | 0.0 | 0.0 | Wrong: "bricked" is not in the lexicon |
| Oh great, another outage. | 0.8 | 0.75 | Wrong: sarcasm |
| Thanks for nothing. | 0.2 | 0.2 | Wrong: idiom |
| I love the screen but the battery is terrible. | -0.25 | 0.8 | One average hides two opinions |
The table shows the four typical failures:
- Unknown words count as nothing. A polarity of 0.0 with a subjectivity of 0.0 often means "no word was found", not "neutral". Product names, slang and domain words are the usual cause.
- Sarcasm and idioms are read literally. "Oh great, another outage." gets the same score as real praise.
- Mixed opinions become one average. A review that likes the screen and hates the battery gets one number near zero.
- Capital letters, punctuation and emoji are ignored. "VERY GOOD!!!" scores the same as "very good!".
The Naive Bayes analyzer
TextBlob has a second analyzer, a Naive Bayes classifier trained on the NLTK movie reviews corpus. It returns a class and two probabilities:
from textblob import Blobber
from textblob.sentiments import NaiveBayesAnalyzer
# python -m textblob.download_corpora (one time: downloads the training data)
tb = Blobber(analyzer=NaiveBayesAnalyzer()) # trains once, then reuse tb
print(tb("The battery life is not great.").sentiment)
# Sentiment(classification='neg', p_pos=0.4189, p_neg=0.5811)The classifier was trained on movie reviews, so its vocabulary fits film criticism better than support tickets or tweets. It has no neutral class.
TextBlob vs VADER
| TextBlob | VADER | |
|---|---|---|
| Output | polarity, subjectivity | neg, neu, pos, compound |
| Made for | General English, product reviews | Social media text |
| Capitals and "!!!" | Ignored | Increase the score |
| Emoji and slang | Ignored | Included in the lexicon |
| "This phone is VERY GOOD!!!" | 1.0 (same as lower case) | 0.76 (0.54 in lower case) |
| Subjectivity score | Yes | No |
| Languages | English | English |
For tweets, chat and comments, VADER is usually the better lexicon method. Details in VADER sentiment analysis explained. Both fail on sarcasm: VADER gives "Oh great, another outage." a compound score of 0.62.
When to use something else
TextBlob is a good choice for a first look at English text, for teaching, and when you cannot install a large model. Change to a different tool in these cases:
- Accuracy matters. A transformer model reads the full sentence, so it handles negation, context and most domain words. See the Python guide for the Hugging Face code.
- Your text is not English. Use a multilingual model. See multilingual sentiment analysis.
- You must know which emotion, not only positive or negative. "Wait, how does this even work? I'm confused." gets a TextBlob polarity of -0.4. An emotion model reports
confusionwith a score of 0.97, which tells a support team what to do. See emotion detection vs sentiment analysis.
The Sentiment API returns scores for 28 emotions and a valence score for each message, in six languages, without a model to host. The GoEmotions API guide shows the request and real output, and sentiment analysis tools compared puts the options side by side.
Frequently asked questions
What does TextBlob sentiment return?
TextBlob(text).sentiment returns two numbers. Polarity runs from -1.0 (negative) to 1.0 (positive). Subjectivity runs from 0.0 (objective, factual) to 1.0 (subjective, opinion).
How does TextBlob calculate polarity?
The default analyzer looks up each word in a lexicon of English words, mostly adjectives, that have a hand-assigned polarity and subjectivity. It averages the values of the words it finds. An intensifier such as "very" multiplies the next word's polarity, and "not" multiplies it by -0.5. Words that are not in the lexicon are ignored.
Why does TextBlob return a polarity of 0.0?
A polarity of 0.0 with a subjectivity of 0.0 usually means that no word in the text is in the lexicon, not that the text is neutral. "The update bricked my phone." scores 0.0 because "bricked" is not a lexicon word.
Is TextBlob or VADER better for sentiment analysis?
VADER is usually better for social media text: it reads capital letters, exclamation marks, emoji and slang. TextBlob is simpler and also gives a subjectivity score. Both are English-only lexicon methods and both miss sarcasm and context, where a transformer model is more accurate.
Does TextBlob work for languages other than English?
The built-in sentiment lexicon is English. Community extensions exist for some languages, such as textblob-de and textblob-fr. The translate() and detect_language() methods that older tutorials use are no longer in TextBlob.