Skip to content

Instantly share code, notes, and snippets.

@jonathanoheix
Created December 18, 2018 09:50
Show Gist options
  • Save jonathanoheix/3030a082a22f3c2f733ca26f9781e7d2 to your computer and use it in GitHub Desktop.
Save jonathanoheix/3030a082a22f3c2f733ca26f9781e7d2 to your computer and use it in GitHub Desktop.
# add sentiment anaylsis columns
from nltk.sentiment.vader import SentimentIntensityAnalyzer
sid = SentimentIntensityAnalyzer()
reviews_df["sentiments"] = reviews_df["review"].apply(lambda x: sid.polarity_scores(x))
reviews_df = pd.concat([reviews_df.drop(['sentiments'], axis=1), reviews_df['sentiments'].apply(pd.Series)], axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment