如何在数据框上应用散点图和折线图进行比特币情感分析?

3

我希望能够创建散点图和折线图,并了解比特币价格与人们推文情绪之间是否存在关系。我有一个包含“复合”、“积极”、“中立”和“消极”的列,希望它们展示比特币价格和人们情绪之间的关系。请问是否有解决方案可以应用各种数据可视化技术来展示比特币情绪和价格随时间的关系?或许像散点图或折线图这样的方式。谢谢!

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
import pandas as pd
from matplotlib import pyplot as plt
import seaborn as sns

analyzer = SentimentIntensityAnalyzer()

df=pd.read_csv('cleaned_with_price.csv', header = 0)
df2 = df.drop(['Unnamed: 0', 'id', 'fullname', 'url', 'timestamp', 'replies', 'likes', 'retweets'], axis=1)

## removed unnecesarry stuff

tweets_list = df2['text'].tolist()
tweet_df = pd.DataFrame(tweets_list, columns = ['Tweet'])
tweet_df

这给出了以下结果, 输入图像描述
## add columns for each score in the dataframe

tweet_df.Tweet = tweet_df.Tweet.astype('str')

df2['Compound'] = [analyzer.polarity_scores(twt)['compound'] for twt in tweet_df['Tweet']]
df2['Positive'] = [analyzer.polarity_scores(twt)['pos'] for twt in tweet_df['Tweet']]
df2['Neutral'] = [analyzer.polarity_scores(twt)['neu'] for twt in tweet_df['Tweet']]
df2['Negative'] = [analyzer.polarity_scores(twt)['neg'] for twt in tweet_df['Tweet']]   
df2

这将输出以下内容: enter image description here

有人能否推荐一种解决方案来应用不同的数据可视化技术,以显示比特币情绪与随时间变化的价格之间的关系?

1个回答

3

如果我理解你的问题正确,可以尝试以下操作:

plt.scatter(df2['Date'], df2['Compound'])
plt.scatter(df2['Date'], df2['Positive'])
...
plt.show()

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接