text_html_output_1.png
from collections import Counter

from wordcloud import WordCloud

import matplotlib.pyplot as plt

import pandas as pd

import plotly.express as px

data = pd.read_csv('../input/sentiment-analysis-for-financial-news/all-data.csv', names=['Sentiment', 'Tweet'], encoding='latin-1')

temp = data.groupby('Sentiment').count()['Tweet'].reset_index().sort_values(by='Tweet', ascending=False)
temp.style.background_gradient(cmap='Purples')

fig = go.Figure(go.Funnelarea(text=temp.Sentiment, values=temp.Tweet, title={'position': 'top center', 'text': 'Distribution des sentiments'}))

text = ' '.join([x for x in data.Tweet])
wordcloud = WordCloud(background_color='white').generate(text)
plt.axis('off')

data['list_mots'] = data['Tweet'].apply(lambda x: str(x).split())
top = Counter([item for sublist in data['list_mots'] for item in sublist])
temp = pd.DataFrame(top.most_common(20))
temp.columns = ['Common_words', 'count']
temp.style.background_gradient(cmap='Blues')

fig = px.bar(temp, x="count", y="Common_words", title='Commmon Words in Selected Text', orientation='h', 
             width=700, height=700,color='Common_words')
fig.show()

top = Counter([item for sublist in data['list_mots'] for item in sublist])
temp = pd.DataFrame(top.most_common(20))
temp = temp.iloc[1:, :]
temp.columns = ['Common_words', 'count']
temp.style.background_gradient(cmap='Purples')

fig = px.bar(temp, x='count', y='Common_words', title='Commmon Words in Selected Text', orientation='h', width=700, height=700, color='Common_words')
fig.show()