pythonpandasdataframevader

Daily Sentiment Values


Does anyone have an idea into calculating the average sentiment values for each day? This is my code get get the sentiment score, but I have tried calculating an average for each of the day, but i havent had any luck

from nltk.sentiment.vader import SentimentIntensityAnalyzer
import pandas as pd
analyzer = SentimentIntensityAnalyzer()

eth = pd.read_csv("Ethereum_2020_2021_Time_Adjusted.csv")
eth['Sentiment Values'] = eth['Title'].apply(lambda Title: analyzer.polarity_scores(Title))
eth['Title Sentiment Score']  = eth['Sentiment Values'].apply(lambda score_dict: score_dict['compound'])

enter image description here


Solution

  • Try using groupby and agg to address the issue.

    eth.groupby('Date')['Sentiment Values'].agg('mean')