text_plain_output_1.png image_output_2.png image_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

df_main = pd.read_csv('../input/zomato.csv')

df_loc = df_main['location'].value_counts()[:20]

df_BTM =df_main.loc[df_main['location']=='BTM']
df_BTM_REST= df_BTM['rest_type'].value_counts()

fig = plt.figure(figsize=(20,10))
ax1 = fig.add_subplot(121)

sns.barplot(x=df_BTM_REST, y= df_BTM_REST.index,ax=ax1)
plt.title('Count of restaurant types in BTM')
plt.xlabel('Count')
plt.ylabel('Restaurant Name')

df_BTM_REST1 = df_BTM_REST[:10]
labels = df_BTM_REST1.index
explode = (0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0)

df_RATE_BTM = df_BTM[['rate', 'rest_type', 'online_order', 'votes', 'book_table', 'approx_cost(for two people)', 'listed_in(type)', 'listed_in(city)']].dropna()
df_RATE_BTM['rate'] = df_RATE_BTM['rate'].apply(lambda x: float(x.split('/')[0]) if len(x) > 3 else 0)
df_RATE_BTM['approx_cost(for two people)'] = df_RATE_BTM['approx_cost(for two people)'].apply(lambda x: int(x.replace(',', '')))
df_rating = df_BTM['rate'].dropna().apply(lambda x: float(x.split('/')[0]) if len(x) > 3 else np.nan).dropna()

f, axes = plt.subplots(1, 2, figsize=(20, 10), sharex=True)
sns.despine(left=True)

sns.distplot(df_rating,bins= 20,ax = axes[0]).set_title('Rating distribution in BTM Region')

plt.xlabel('Rating')

df_grp= df_RATE_BTM.groupby(by= 'rest_type').agg('mean').sort_values(by='votes', ascending=False)

sns.distplot(df_grp['rate'],bins= 20,ax = axes[1]).set_title('Average Rating distribution in BTM Region')

df_grp.reset_index(inplace=True)

df_grp1 = df_RATE_BTM.groupby(by='rest_type').agg('mean').sort_values(by='rate', ascending=False)
plt.xlim(2.5, 5)

df_grp2 = df_RATE_BTM.groupby(by='rest_type').agg('mean').sort_values(by='approx_cost(for two people)', ascending=False)

df_Count_CasualDinning = df_main.loc[df_main['rest_type'] == 'Casual Dining, Bar'].groupby(by='location').agg('count').sort_values(by='rest_type')

df_count_casual = df_main.loc[df_main['rest_type'] == 'Casual Dining, Microbrewery'].groupby(by='location').agg('count').sort_values(by='rest_type')

sns.barplot(x=df_count_casual['name'], y=df_count_casual.index).set_title('Number of Casual Dining, Microbrewery in Bengaluru ')
plt.xlabel('Count')