Created
April 13, 2023 03:38
-
-
Save srang992/7a2aabd6e6dd6f60ea723e47669c6e3d 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
# taking the all cocoa percentages uses in chocolates of soma chocomaker | |
cocoa_list = list(soma_choco_data['cocoa_percent']) | |
# creating a dictionary | |
cocoa_percent_dict = {} | |
for cocoa_percent in cocoa_list: | |
if str(cocoa_percent) in cocoa_percent_dict: | |
cocoa_percent_dict[str(cocoa_percent)] += 1 | |
else: | |
cocoa_percent_dict[str(cocoa_percent)] = 1 | |
# sorting the dictionary in decending order | |
cocoa_percent_dict = sort_sliced_dict(cocoa_percent_dict, item_count=5) | |
# plotting the data | |
fig = px.pie(names=list(cocoa_percent_dict.keys()), | |
values=list(cocoa_percent_dict.values()), | |
title='Mostly used Cocoa Percentage in chocolates made by Soma ChocoMaker', | |
color_discrete_sequence=px.colors.sequential.Agsunset) | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment