Forked from databrit/sentiment_analysis_top_100_songs.py
Created
December 14, 2016 14:42
-
-
Save radovankavicky/7ed498b4c3c5c85903c03a6bbc7d283f 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
import pandas as pd | |
import time | |
from nltk.sentiment import SentimentIntensityAnalyzer | |
t0 = time.time() | |
top_100 = pd.read_csv('/Users/brit.cava/Desktop/TabPy/top100.csv') | |
text = top_100['Word'] | |
sid = SentimentIntensityAnalyzer() | |
word_score_dict = {} | |
for word in text: | |
ss = sid.polarity_scores(word) | |
word_score_dict[word]=(ss['compound']) | |
t1 = time.time() | |
total = t1-t0 | |
print(total) | |
df = pd.DataFrame(list(word_score_dict.iteritems()), columns=['word','score']) | |
df.to_csv("/Users/brit.cava/Desktop/Scores.csv", index=False, cols=('word','score')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment