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
df_food = pd.read_csv('C:\\Users\Dell\\Desktop\\train_food\\train_food.csv') | |
df_food.head() |
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
df = pd.merge(df_food,df_center,on='center_id') | |
df = pd.merge(df,df_meal,on='meal_id') |
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
table = pd.pivot_table(data=df,index='category',values='num_orders',aggfunc=np.sum) | |
table |
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
#bar graph | |
plt.bar(table.index,table['num_orders']) | |
#xticks | |
plt.xticks(rotation=70) | |
#x-axis labels | |
plt.xlabel('Food item') | |
#y-axis labels |
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
#dictionary for meals per food item | |
item_count = {} | |
for i in range(table.index.nunique()): | |
item_count[table.index[i]] = table.num_orders[i]/df_meal[df_meal['category']==table.index[i]].shape[0] | |
#bar plot | |
plt.bar([x for x in item_count.keys()],[x for x in item_count.values()],color='orange') | |
#adjust xticks |
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
#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 |
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
#pie plot | |
plt.pie([x*100 for x in d_cuisine.values()],labels=[x for x in d_cuisine.keys()],autopct='%0.1f',explode=[0,0,0.1,0]) | |
#label the plot | |
plt.title('Cuisine share %') | |
plt.savefig('C:\\Users\\Dell\\Desktop\\AV Plotting images\\matplotlib_plotting_8.png',dpi=300,bbox_inches='tight') | |
plt.show(); |
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
#dictionary for base price per cuisine | |
c_price = {} | |
for i in df['cuisine'].unique(): | |
c_price[i] = df[df['cuisine']==i].base_price |
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
#plotting boxplot | |
plt.boxplot([x for x in c_price.values()],labels=[x for x in c_price.keys()]) | |
#x and y-axis labels | |
plt.xlabel('Cuisine') | |
plt.ylabel('Price') | |
#plot title | |
plt.title('Analysing cuisine price') |
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
#plotting histogram | |
plt.hist(df['base_price'],rwidth=0.9,alpha=0.3,color='blue',bins=15,edgecolor='red') | |
#x and y-axis labels | |
plt.xlabel('Base price range') | |
plt.ylabel('Distinct order') | |
#plot title | |
plt.title('Inspecting price effect') |