Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created March 12, 2020 17:35
Show Gist options
  • Save aniruddha27/1d976786d57e9357214730bb1167975f to your computer and use it in GitHub Desktop.
Save aniruddha27/1d976786d57e9357214730bb1167975f to your computer and use it in GitHub Desktop.
#dictionary for cuisine and its total orders
d_cuisine = {}
#total number of order
total = df['num_orders'].sum()
#find ratio of orders per cuisine
for i in range(df['cuisine'].nunique()):
#cuisine
c = df['cuisine'].unique()[i]
#num of orders for the cuisine
c_order = df[df['cuisine']==c]['num_orders'].sum()
d_cuisine[c] = c_order/total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment