Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Sentiment analysis using Textblob
def sentiment(tweet):
analysis = TextBlob(tweet)
if analysis.sentiment.polarity > 0:
return 1
elif analysis.sentiment.polarity == 0:
return 0
else:
return -1
df_tweet['Sentiment'] = df_tweet['Clean_Tweet'].apply(sentiment)
df_tweet.head(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment