Created
August 15, 2020 05:40
-
-
Save aniruddha27/7d1a63ddaed056009d6f7ad88a9714fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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