Skip to content

Instantly share code, notes, and snippets.

@srang992
Created April 13, 2023 04:10
Show Gist options
  • Save srang992/7f857ff88d19646a4f8c3384edd62dd0 to your computer and use it in GitHub Desktop.
Save srang992/7f857ff88d19646a4f8c3384edd62dd0 to your computer and use it in GitHub Desktop.
# removing the misspelled word
taste_codo['nutty'] = taste_codo['nut'] + taste_codo['nuts'] + taste_codo['nutty']
taste_codo['woody'] = taste_codo['woodsy'] + taste_codo['woody']
taste_codo['earthy'] = taste_codo['earth'] + taste_codo['earthy']
taste_codo.drop(['nut', 'nuts', 'woodsy', 'earth'], axis=1, inplace=True)
# making the taste dictionary
tasty_dict = {}
tasty_list = list(taste_codo.columns)
for taste in tasty_list:
tasty_dict[taste] = sum(taste_codo[taste])
# sorting the dictionary in decending order
tasty_dict = sort_sliced_dict(tasty_dict, is_reverse=True, item_count=7)
# plotting the graph
fig = px.bar(x=list(tasty_dict.keys()),
y=list(tasty_dict.values()),
color_continuous_scale='viridis',
color=list(tasty_dict.keys()))
fig.update_layout(title={'text': 'Most Memorable Taste of Chocolates made by Soma Chocomaker'},
xaxis={'title_text': 'Tastes'},
yaxis={'title_text': 'Count'})
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment