text_plain_output_1.png
from json  import loads , dumps

import pandas as pd

file = open('/kaggle/input/swiggy-restaurants-dataset/data.json', 'r')
data = file.read()
file.close()
js = loads(data)

cuisines = []
for i in js['Abohar']['restaurants'].keys():
    cuisines += js['Abohar']['restaurants'][i]['cuisine'].split(',')
cuisines = list(set(cuisines))

pop_cui = []
for cuisine in cuisines:
    c = 0
    for i in js['Abohar']['restaurants'].keys():
        if cuisine in js['Abohar']['restaurants'][i]['cuisine']:
            c += 1
    pop_cui.append([cuisine, c])
df = pd.DataFrame(pop_cui, columns=['item', 'freq'])
df[df['freq'] == max(df['freq'])]

pop_cui = []
for cuisine in cuisines:
    c = 0
    for i in js['Abohar']['restaurants'].keys():
        if cuisine in js['Abohar']['restaurants'][i]['cuisine']:
            c += 1
    pop_cui.append([cuisine, c])
df = pd.DataFrame(pop_cui, columns=['item', 'freq'])
df.sort_values(by='freq', ascending=False).head(5)

price = []
for i in js['Abohar']['restaurants'].keys():
    if 'North Indian' in js['Abohar']['restaurants'][i]['cuisine']:
        price.append(int(js['Abohar']['restaurants'][i]['cost'].split(' ')[-1]))

avg_cuisine = []
for cuisine in cuisines:
    price = []
    for i in js['Abohar']['restaurants'].keys():
        if cuisine in js['Abohar']['restaurants'][i]['cuisine']:
            price.append(int(js['Abohar']['restaurants'][i]['cost'].split(' ')[-1]))
    avg_cuisine.append([cuisine, sum(price) // len(price)])
avg_cuisine = pd.DataFrame(avg_cuisine, columns=['cuisine', 'avg_cost'])
avg_cuisine.head()