Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created June 6, 2021 12:30
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/b2e2d9eb30e3cf2f81afdea1755647bd to your computer and use it in GitHub Desktop.
Save amankharwal/b2e2d9eb30e3cf2f81afdea1755647bd to your computer and use it in GitHub Desktop.
df = pd.DataFrame(data, columns=["Date", 'Time', 'Author', 'Message'])
df['Date'] = pd.to_datetime(df['Date'])
data = df.dropna()
from nltk.sentiment.vader import SentimentIntensityAnalyzer
sentiments = SentimentIntensityAnalyzer()
data["Positive"] = [sentiments.polarity_scores(i)["pos"] for i in data["Message"]]
data["Negative"] = [sentiments.polarity_scores(i)["neg"] for i in data["Message"]]
data["Neutral"] = [sentiments.polarity_scores(i)["neu"] for i in data["Message"]]
print(data.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment