3

I want to be able to create a scatter plot and line chart and find out if there is a relationship between the price of Bitcoin and the sentiments of the tweets of the people. I have a column that is Compound, Positive, Neutral, and Negative and I want them to show the relationship between Bitcoin price and the sentiment of the people. Can someone recommend a solution on how to apply various data visualization techniques to show the relationship between Bitcoin sentiments and the price over time? Maybe something like a scatter plot or a line chart. Thank you!

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

Which gives this, enter image description here

## 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

Which outputs this: enter image description here

Can someone recommend a solution on how to apply various data visualization techniques to show the relationship between Bitcoin sentiments and the price over time?

petezurich
  • 9,280
  • 9
  • 43
  • 57

1 Answers1

3

If I understand your question correctly, try something like this:

plt.scatter(df2['Date'], df2['Compound'])
plt.scatter(df2['Date'], df2['Positive'])
...
plt.show()
Alexander Korovin
  • 1,639
  • 1
  • 12
  • 19