# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
#import plotly.plotly as py
#import plotly.graph_objs as go

#py.offline.init_notebook_mode(connected=True)

# #%matplotlib notebook
# %matplotlib inline

import warnings
warnings.filterwarnings('ignore')
# -

zom_data = pd.read_csv('C:\DCU_Data_Analytics\Data_Management_And_Visualisation\Assignment\Zomato_bangalore\zomato.csv')

zom_data.head()

zom_data

zom_data.info()

zom_data.columns

zom_data.isna().sum()

zom_data=zom_data[zom_data.cuisines.isna()==False]

zom_data.isna().sum()

zom_data.dtypes

zom_data.drop(columns=["url", 'address','phone','menu_item','reviews_list'], axis=1, inplace  =True)

zom_data

zom_data.rename(columns={"approx_cost(for two people)": "avg_cost_2", "listed_in(type)":"meal_type", "listed_in(city)":"Area"}, inplace = True)

zom_data

zom_data.isna().sum()

zom_data.duplicated().sum()

zom_data.drop(columns=['location'], axis=1, inplace  =True)

zom_data

zom_data.isnull().sum()

zom_data['rate'] = zom_data['rate'].apply(lambda x: str(x).split('/')[0])

zom_data['avg_cost_2'] = zom_data['avg_cost_2'].apply(lambda x: str(x).replace(',',''))

cuisines_data = zom_data[zom_data.cuisines.notnull()]
cuisines_data.cuisines = cuisines_data.cuisines.apply(lambda x:x.lower().strip())

zom_data['rate'] = zom_data['rate'].replace('NEW',np.NaN)
zom_data["dish_liked"].fillna("No dish liked", inplace = True)  


# +

zom_data["rate"].fillna('nan', inplace = True)  
# -

zom_data.isnull().sum()

zom_data["rest_type"].fillna('nan', inplace = True) 

zom_data.isnull().sum()

zom_data['rate'] = zom_data['rate'].replace('-','nan')

zom_data.to_csv(r'C:\DCU_Data_Analytics\Data_Management_And_Visualisation\Assignment\Zomato_bangalore\zomato_clean2.csv', index=False)

print (zom_data['Area'])

colors  = ("grey", "blue", "indigo", "beige", "yellow","red", "green", "orange", "cyan", "brown")

# +
fig= plt.figure(figsize=(18, 9))
explode = (0.1, 0, 0, 0,0,0,0,0,0,0) 

delplot = zom_data['avg_cost_2'].value_counts()[:10].plot(kind = 'pie',autopct='%1.1f%%',fontsize=20,shadow=True,explode = explode,colors=colors)

#draw circle
centre_circle = plt.Circle((0,0),0.80,fc='white')
fig = plt.gcf()
fig.gca().add_artist(centre_circle)

plt.title("Average cost for 2 people in Rupees",fontsize = 25,weight = 'bold')
# -

colors = ['yellow','red','brown','orange','#00FF00','#FF00FF']

# +
plt.figure(figsize = (12,6))
names = zom_data['rest_type'].value_counts()[:6].index
values = zom_data['rest_type'].value_counts()[:6].values
explode = (0.1, 0, 0, 0,0,0)  # explode 1st slice

plt.title('Type of restaurant in percentage', weight = 'bold')
plt.pie(values, explode=explode, labels=names, colors=colors,autopct='%1.1f%%', shadow=True, startangle=140)
plt.axis('equal')
plt.show()
# -



StarcoderdataJupyterScriptsDedupFiltered