Skip to content

Instantly share code, notes, and snippets.

@kurasaiteja
Created August 5, 2020 11:32
Show Gist options
  • Save kurasaiteja/e5acefc218b28f524cd3881d356ebee0 to your computer and use it in GitHub Desktop.
Save kurasaiteja/e5acefc218b28f524cd3881d356ebee0 to your computer and use it in GitHub Desktop.
def visualize_emoji(data):
total_emojis_list = list([a for b in messages_df.emoji for a in b])
emoji_dict = dict(Counter(total_emojis_list))
emoji_dict = sorted(emoji_dict.items(), key=lambda x: x[1], reverse=True)
emoji_df = pd.DataFrame(emoji_dict, columns=['emoji', 'count'])
fig = px.pie(emoji_df, values='count', names='emoji')
fig.update_traces(textposition='inside', textinfo='percent+label')
fig.update_layout(
margin=dict(
l=5,
r=5,
)
)
fig.update(layout_showlegend=False)
return fig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment