Created
April 13, 2023 04:05
-
-
Save srang992/5eaae3748fc0c5bab4d66a2179b6f96b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# filtering those chocolates which are manufactured by Soma Chocomaker | |
soma_choco_data = choco_data[choco_data['manufacturer'].isin(['Soma'])] | |
# creating the dictionary | |
bean_dict = {} | |
bean_origins = list(soma_choco_data['bean_origin']) | |
for origin in bean_origins: | |
if origin in bean_dict: | |
bean_dict[origin] += 1 | |
else: | |
bean_dict[origin] = 1 | |
# creating the dictionary | |
bean_dict = sort_sliced_dict(bean_dict, is_reverse=True, item_count=5) | |
# plotting the graph | |
fig = px.bar(x=list(bean_dict.keys()), | |
y=list(bean_dict.values()), | |
text=list(bean_dict.values()), | |
color_continuous_scale='inferno', | |
color=list(bean_dict.keys())) | |
fig.update_traces(textposition='outside') | |
fig.update_layout(title={'text': 'Beans providers for Soma'}, | |
xaxis={'title_text': 'Beans Origin'}, | |
yaxis={'title_text': 'Count'}) | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment