Skip to content

Instantly share code, notes, and snippets.

View aniruddha27's full-sized avatar

Aniruddha Bhandari aniruddha27

View GitHub Profile
#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();
#dictionary for base price per cuisine
c_price = {}
for i in df['cuisine'].unique():
c_price[i] = df[df['cuisine']==i].base_price
#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')
#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')
#new revenue column
df['revenue'] = df.apply(lambda x: x.checkout_price*x.num_orders,axis=1)
#new month column
df['month'] = df['week'].apply(lambda x: x//4)
#list to store month-wise revenue
month=[]
month_order=[]
#subplots returns a Figure and an Axes object
fig,ax=plt.subplots(nrows=1,ncols=2,figsize=(20,5))
#manipulating the first Axes
ax[0].plot(week,week_order)
ax[0].set_xlabel('Week')
ax[0].set_ylabel('Revenue')
ax[0].set_title('Weekly income')
#manipulating the second Axes
center_type_name = ['TYPE_A','TYPE_B','TYPE_C']
#relation between op area and number of orders
op_table=pd.pivot_table(df,index='op_area',values='num_orders',aggfunc=np.sum)
#relation between center type and op area
c_type = {}
for i in center_type_name:
c_type[i] = df[df['center_type']==i].op_area
train = pd.read_csv('/kaggle/input/house-prices-advanced-regression-techniques/train.csv')
test = pd.read_csv('/kaggle/input/house-prices-advanced-regression-techniques/test.csv')