Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created October 12, 2021 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/24c0266c051be45e2401ce4dd9c12fd7 to your computer and use it in GitHub Desktop.
Save amankharwal/24c0266c051be45e2401ce4dd9c12fd7 to your computer and use it in GitHub Desktop.
nltk.download('vader_lexicon')
sentiments = SentimentIntensityAnalyzer()
data["Positive"] = [sentiments.polarity_scores(i)["pos"] for i in data["text"]]
data["Negative"] = [sentiments.polarity_scores(i)["neg"] for i in data["text"]]
data["Neutral"] = [sentiments.polarity_scores(i)["neu"] for i in data["text"]]
data = data[["text", "Positive", "Negative", "Neutral"]]
print(data.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment