text_html_output_1.png
import numpy as np

import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

import pandas as pd
import numpy as np
import re
import seaborn as sns
df = pd.read_csv('/kaggle/input/zomato-eda/zomato.csv').copy()

df = df.rename(columns={'listed_in(city)': 'city', 'listed_in(type)': 'type', 'approx_cost(for two people)': 'cost'})
df = df.drop(columns=['url', 'address', 'phone', 'dish_liked', 'reviews_list', 'menu_item'])

df = df.dropna()

df.isnull().sum()

df['rate'].replace('NEW', np.nan, inplace=True)
df['rate'].replace('-', np.nan, inplace=True)
df = df.dropna()
df['rate'].unique()

df.cost.unique()

df.cost.unique()

test = df.iloc[[2]].copy()
test['cuisines'] = test['cuisines'].astype(str)
test

df['cuisines'] = df['cuisines'].str.split(',')
df = df.explode('cuisines')
df
df['rest_type'] = df['rest_type'].str.split(',')
df = df.explode('rest_type')
df.reset_index(drop=True)

df.rate = df.rate.astype('float')
type(df.rate[0])

X = df.groupby(['location']).count()
X.loc[X['name'] == X['name'].max()].index.tolist()

X = df.groupby(['location']).mean()
A = X.sort_values(by=['rate'], ascending=False)
B = X.sort_values(by=['rate'])
a = A.iloc[0:5]
b = B.iloc[0:5]
a['rate'].plot(kind='bar')