Untitled
unknown
python
2 years ago
975 B
4
Indexable
import nltk nltk.download('vader_lexicon') from nltk.sentiment.vader import SentimentIntensityAnalyzer positive_words = 'buy bull long support undervalued underpriced cheap upward rising trend moon rocket hold hodl breakout call beat support buying holding high profit stonks yolo' negative_words = 'sell bear bubble bearish short overvalued overbought overpriced expensive downward falling sold sell low put miss resistance squeeze cover seller loss ' pos = {i: 5 for i in positive_words.split(" ")} neg = {i: -5 for i in negative_words.split(" ")} stock_lexicons = {**pos, **neg} vadar_analyzer = SentimentIntensityAnalyzer() vadar_analyzer.lexicon.update(stock_lexicons) def process_headline(headline): return vadar_analyzer.polarity_scores(headline)['compound'] ts_df['sentiment_score'] = ts_df['headline'].apply(process_headline) # Cell 2 ts_df.head(5) # Cell 3 ts_df.sample(10) # Cell 4 import seaborn as sns sns.violinplot(ts_df)