Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created October 1, 2020 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/3324ea451effec59f11d615cd932a7d9 to your computer and use it in GitHub Desktop.
Save amankharwal/3324ea451effec59f11d615cd932a7d9 to your computer and use it in GitHub Desktop.
count_1 = df_subset_trump.groupby('Expression Label').count()
print(count_1)
negative_per1 = (count_1['Sentiment Polarity'][0]/1000)*10
positive_per1 = (count_1['Sentiment Polarity'][1]/1000)*100
count_2 = df_subset_biden.groupby('Expression Label').count()
print(count_2)
negative_per2 = (count_2['Sentiment Polarity'][0]/1000)*100
positive_per2 = (count_2['Sentiment Polarity'][1]/1000)*100
Politicians = ['Joe Biden', 'Donald Trump']
lis_pos = [positive_per1, positive_per2]
lis_neg = [negative_per1, negative_per2]
fig = go.Figure(data=[
go.Bar(name='Positive', x=Politicians, y=lis_pos),
go.Bar(name='Negative', x=Politicians, y=lis_neg)
])
# Change the bar mode
fig.update_layout(barmode='group')
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment