Spaces:
Sleeping
Sleeping
Commit
•
3937cb7
1
Parent(s):
d2f4246
Update app.py
Browse files
app.py
CHANGED
@@ -1,134 +1,276 @@
|
|
1 |
import pandas as pd
|
2 |
-
import numpy as np
|
3 |
-
import panel as pn
|
4 |
-
pn.extension('tabulator')
|
5 |
-
|
6 |
-
import hvplot.pandas
|
7 |
-
|
8 |
-
project_data = pd.read_csv(r'DMart.csv')
|
9 |
-
project_data.columns
|
10 |
-
project_data.info()
|
11 |
-
project_data.describe()
|
12 |
-
project_data.isna().sum()
|
13 |
-
project_data.shape
|
14 |
-
project_data['Brand'] = project_data['Brand'].fillna('others')
|
15 |
-
project_data.isna().sum()
|
16 |
-
project_data = project_data.dropna()
|
17 |
-
project_data.isna().sum()
|
18 |
-
df = pd.DataFrame(project_data)
|
19 |
-
idf = df.interactive()
|
20 |
-
df.groupby(by=["SubCategory","Quantity"], dropna=False, sort=True).sum()
|
21 |
import pandas as pd
|
22 |
import panel as pn
|
23 |
import hvplot.pandas
|
24 |
-
|
25 |
-
|
26 |
-
import
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
# Assuming your dataset is stored in a DataFrame called 'df'
|
31 |
-
|
32 |
-
# Create an interactive DataFrame
|
33 |
-
idf = df.interactive()
|
34 |
-
|
35 |
-
# Define Panel widgets for Top 10 Brands and Top 10 Categories
|
36 |
-
brand_count = df['Brand'].value_counts().nlargest(10)
|
37 |
-
category_count = df['Category'].value_counts().nlargest(10)
|
38 |
-
|
39 |
-
# Define the hvplot charts with increased size
|
40 |
-
brand_chart = brand_count.hvplot.bar(rot=90, title='Top 10 Brands', color=['#206b33'], width=800, height=400) # Different shades of green
|
41 |
-
category_chart = category_count.hvplot.bar(rot=90, title='Top 10 Categories', color=['#206b33'], width=800, height=400)
|
42 |
-
|
43 |
-
# Create brand_price and category_price dictionaries
|
44 |
-
brand_price = {}
|
45 |
-
category_price = {}
|
46 |
-
|
47 |
-
def brand_and_top_price():
|
48 |
-
for index, row in project_data.iterrows():
|
49 |
-
if row["Brand"] in brand_price:
|
50 |
-
if brand_price.get(row["Brand"]) < row["Price"]:
|
51 |
-
brand_price[row["Brand"]] = row["Price"]
|
52 |
-
else:
|
53 |
-
brand_price[row["Brand"]] = row["Price"]
|
54 |
-
|
55 |
-
def category_and_top_price():
|
56 |
-
for index, row in project_data.iterrows():
|
57 |
-
if row["Category"] in category_price:
|
58 |
-
if category_price.get(row["Category"]) < row["Price"]:
|
59 |
-
category_price[row["Category"]] = row["Price"]
|
60 |
-
else:
|
61 |
-
category_price[row["Category"]] = row["Price"]
|
62 |
-
|
63 |
-
brand_and_top_price()
|
64 |
-
category_and_top_price()
|
65 |
-
project_data_interactive = project_data.interactive()
|
66 |
-
idf = df.interactive()
|
67 |
|
68 |
-
#
|
69 |
-
|
70 |
-
|
71 |
-
#
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
# Define Panel widgets
|
97 |
yaxis_radio = pn.widgets.RadioButtonGroup(
|
98 |
name='Y axis',
|
99 |
-
options=['
|
100 |
-
button_type='
|
101 |
-
inline=True
|
|
|
102 |
)
|
103 |
|
104 |
# Define the Panel layout
|
105 |
panel_layout = pn.Column(
|
106 |
-
yaxis_radio
|
107 |
)
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
# Define the callback function for the radio button
|
110 |
def update_chart(event):
|
111 |
-
if event.new == '
|
112 |
-
panel_layout[1:] = [
|
113 |
-
elif event.new == '
|
114 |
-
panel_layout[1:]
|
115 |
-
elif event.new == '
|
116 |
-
panel_layout[1:] = [
|
117 |
-
elif event.new == 'Top
|
118 |
-
panel_layout[1:] = [
|
119 |
-
elif event.new == '
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
yaxis_radio.param.watch(update_chart, 'value')
|
129 |
|
130 |
# Display the initial chart
|
131 |
-
panel_layout.append(
|
132 |
|
133 |
# Display the Panel layout
|
134 |
panel_layout
|
@@ -138,29 +280,26 @@ pn.extension() # Add this line to load the Panel extension
|
|
138 |
|
139 |
# Layout using Template
|
140 |
template = pn.template.FastListTemplate(
|
141 |
-
title='
|
142 |
sidebar=[
|
143 |
-
pn.pane.PNG('
|
144 |
-
pn.pane.Markdown("#
|
145 |
-
pn.pane.Markdown("1.
|
146 |
-
pn.pane.Markdown("2.
|
147 |
-
pn.pane.Markdown("3.
|
148 |
-
pn.pane.Markdown("4.
|
149 |
-
pn.pane.Markdown("5.
|
150 |
-
pn.pane.Markdown("6.
|
151 |
-
pn.pane.Markdown("7.
|
152 |
-
pn.pane.Markdown("8.
|
|
|
|
|
153 |
],
|
154 |
main = [pn.Row(pn.Column(dashboard)),
|
155 |
-
pn.Row(pn.pane.Markdown("DMart is a one-stop supermarket chain that aims to offer customers a wide range of basic home and personal products under one roof. Each DMart store stocks home utility products - including food, toiletries, beauty products, garments, kitchenware, bed and bath linen, home appliances and more - available at competitive prices that our customers appreciate. Our core objective is to offer customers good products at great value.DMart was started by Mr. Radhakishan Damani and his family to address the growing needs of the Indian family. From the launch of its first store in Powai in 2002, DMart today has a well-established presence in 327 locations across India. With D-marts mission is to be the lowest priced retailer in the regions we operate, our business continues to grow with new locations planned in more cities.The supermarket chain of DMart stores is owned and operated by Avenue Supermarts Ltd. (ASL). The company has its headquarters in Mumbai.The brands D Mart, D Mart Minimax, D Mart Premia, D Homes, Dutch Harbour, etc are brands owned by ASL.")),
|
156 |
pn.Row(pn.pane.Markdown("Designed and Developed with ❤️ by Chitranshu Nagdawane © 2023"))
|
157 |
],
|
158 |
-
accent_base_color="#
|
159 |
-
header_background="#
|
160 |
)
|
161 |
|
162 |
template.servable()
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
1 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import pandas as pd
|
3 |
import panel as pn
|
4 |
import hvplot.pandas
|
5 |
+
from itertools import cycle
|
6 |
+
from bokeh.palettes import Reds9
|
7 |
+
import folium
|
8 |
+
raw_df = pd.read_csv('zomato_data.csv')
|
9 |
+
zomato_df = raw_df.copy()
|
10 |
+
rating_type_df = zomato_df['RATING_TYPE'].value_counts().reset_index()
|
11 |
+
rating_type_df.rename(columns={'index':'RATING TYPE', 'RATING_TYPE':'COUNT OF RESTAURANTS'}, inplace=True)
|
12 |
+
foodtruck_df = zomato_df[zomato_df['CUSINE TYPE'] == 'Food Truck']
|
13 |
+
foodtruck_df.sort_values(by='RATING',ascending=False)
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
# Read the CSV file into a DataFrame
|
17 |
+
zomato_df = pd.read_csv('zomato_data.csv')
|
18 |
+
|
19 |
+
# Count the occurrences of each cuisine type
|
20 |
+
cuisine_counts = zomato_df['CUSINE TYPE'].value_counts()
|
21 |
+
|
22 |
+
# Create the bar plot using hvplot
|
23 |
+
bar_plot_cuisine = cuisine_counts.hvplot.bar(
|
24 |
+
color='#E10F14',
|
25 |
+
title='No. of Restaurants by Cuisine Type',
|
26 |
+
xlabel='Cuisine Type',
|
27 |
+
ylabel='Count',
|
28 |
+
width=900,
|
29 |
+
height=500
|
30 |
+
).opts(xrotation=90)
|
31 |
+
|
32 |
+
# Wrap the bar plot in a Panel object
|
33 |
+
panel_cuisine = pn.panel(bar_plot_cuisine)
|
34 |
+
|
35 |
+
# Create a DataFrame with the given data
|
36 |
+
rating_type_df = pd.DataFrame({
|
37 |
+
'RATING TYPE': ['Average', 'Good', 'Very Good', 'Excellent', 'Poor', 'Very Poor'],
|
38 |
+
'COUNT OF RESTAURANTS': [4983, 4263, 1145, 96, 56, 4]
|
39 |
+
})
|
40 |
+
|
41 |
+
# Define the hvplot chart
|
42 |
+
bar_plot_rating = rating_type_df.hvplot.bar(
|
43 |
+
x='RATING TYPE',
|
44 |
+
y='COUNT OF RESTAURANTS',
|
45 |
+
color='#E10F14',
|
46 |
+
title='Count of Restaurants by Rating Type',
|
47 |
+
xlabel='Rating Type',
|
48 |
+
ylabel='Count',
|
49 |
+
width=900,
|
50 |
+
height=500
|
51 |
+
)
|
52 |
+
|
53 |
+
# Wrap the bar plot in a Panel object
|
54 |
+
panel_rating = pn.panel(bar_plot_rating)
|
55 |
+
|
56 |
+
# Filter food trucks in Mumbai
|
57 |
+
foodtruck_df = zomato_df[zomato_df['CUSINE TYPE'] == 'Food Truck']
|
58 |
+
|
59 |
+
# Sort by rating in descending order and select the top result
|
60 |
+
best_food_truck = foodtruck_df.sort_values(by='RATING', ascending=False).head()
|
61 |
+
|
62 |
+
# Create the bar plot using hvplot
|
63 |
+
bar_plot_best_food_truck = best_food_truck.hvplot.bar(
|
64 |
+
x='NAME',
|
65 |
+
y='PRICE',
|
66 |
+
color='#E10F14',
|
67 |
+
title='Best Food Truck in Mumbai: Price vs. Name',
|
68 |
+
xlabel='Food Truck Name',
|
69 |
+
ylabel='Price',
|
70 |
+
hover_cols=['RATING', 'REGION', 'CUSINE_CATEGORY'],
|
71 |
+
rot=90,
|
72 |
+
width=900,
|
73 |
+
height=500
|
74 |
+
)
|
75 |
+
|
76 |
+
# Wrap the bar plot in a Panel object
|
77 |
+
panel_best_food_truck = pn.panel(bar_plot_best_food_truck)
|
78 |
+
|
79 |
+
# Filter seafood restaurants in Mumbai
|
80 |
+
seafood_df = zomato_df[zomato_df['CUSINE_CATEGORY'].notna() & zomato_df['CUSINE_CATEGORY'].str.contains('Seafood')]
|
81 |
+
|
82 |
+
# Get top 10 seafood restaurants in Mumbai, sorted by rating
|
83 |
+
top_seafood_df = seafood_df.sort_values(by='RATING', ascending=False).head(10)
|
84 |
+
|
85 |
+
# Create the bar plot using hvplot
|
86 |
+
bar_plot_top_seafood = top_seafood_df.hvplot.bar(
|
87 |
+
x='NAME',
|
88 |
+
y='PRICE',
|
89 |
+
color='#E10F14',
|
90 |
+
title='Top 10 Seafood Restaurants in Mumbai: Price vs. Name',
|
91 |
+
xlabel='Restaurant Name',
|
92 |
+
ylabel='Price',
|
93 |
+
hover_cols=['RATING', 'REGION', 'CUSINE_CATEGORY'],
|
94 |
+
rot=90,
|
95 |
+
width=900,
|
96 |
+
height=500
|
97 |
+
)
|
98 |
+
|
99 |
+
# Wrap the bar plot in a Panel object
|
100 |
+
panel_top_seafood = pn.panel(bar_plot_top_seafood)
|
101 |
|
102 |
# Define Panel widgets
|
103 |
yaxis_radio = pn.widgets.RadioButtonGroup(
|
104 |
name='Y axis',
|
105 |
+
options=['Cuisine Type', 'Rating Type', 'Best Food Truck', 'Top 10 Seafood', 'Highest Rated', 'Top Avg Price', 'Chinese Resto', 'Price vs Rating', 'Region vs Price', 'Map'],
|
106 |
+
button_type='danger',
|
107 |
+
inline=True,
|
108 |
+
value='Cuisine Type'
|
109 |
)
|
110 |
|
111 |
# Define the Panel layout
|
112 |
panel_layout = pn.Column(
|
113 |
+
pn.Row(yaxis_radio)
|
114 |
)
|
115 |
|
116 |
+
# Create the map centered at Mumbai with dark mode
|
117 |
+
mumbai_map = folium.Map(location=[19.0760, 72.8777], zoom_start=12, tiles="StamenTonerBackground")
|
118 |
+
|
119 |
+
# Add a marker for Mumbai
|
120 |
+
folium.Marker(
|
121 |
+
location=[19.0760, 72.8777],
|
122 |
+
popup='<b>Mumbai</b>',
|
123 |
+
icon=folium.Icon(color='red', icon_color='white', icon='heart', prefix='fa')
|
124 |
+
).add_to(mumbai_map)
|
125 |
+
|
126 |
+
# Add markers for the specified locations
|
127 |
+
locations = [
|
128 |
+
{'name': 'Hitchki', 'region': 'Bandra', 'rating': '4.8', 'latitude': 19.0590, 'longitude': 72.8292, 'cuisine': 'Indian'},
|
129 |
+
{'name': 'Downtown China', 'region': 'Andheri', 'rating': '4.9', 'latitude': 19.1136, 'longitude': 72.8697, 'cuisine': 'Chinese'},
|
130 |
+
{'name': 'The Northern Vibe', 'region': 'Powai', 'rating': '4.7', 'latitude': 19.1187, 'longitude': 72.9073, 'cuisine': 'Continental'},
|
131 |
+
{'name': 'Rajdhani', 'region': 'Ghatkopar', 'rating': '4.8', 'latitude': 19.0866, 'longitude': 72.9081, 'cuisine': 'Indian'},
|
132 |
+
{'name': 'Trumpet Sky Lounge', 'region': 'Andheri', 'rating': '4.9', 'latitude': 19.1189, 'longitude': 72.8537, 'cuisine': 'International'},
|
133 |
+
{'name': 'Dessertino', 'region': 'Kandivali', 'rating': '4.7', 'latitude': 19.2128, 'longitude': 72.8376, 'cuisine': 'Desserts'}
|
134 |
+
]
|
135 |
+
|
136 |
+
for location in locations:
|
137 |
+
popup_content = f"<b>Name:</b> {location['name']}<br><b>Region:</b> {location['region']}<br><b>Rating:</b> {location['rating']}<br><b>Cuisine:</b> {location['cuisine']}"
|
138 |
+
if location['name'] == 'Dessertino':
|
139 |
+
icon = folium.Icon(color='red', icon_color='white', icon='coffee', prefix='fa')
|
140 |
+
else:
|
141 |
+
icon = folium.Icon(color='red', icon_color='white', icon='cutlery', prefix='fa')
|
142 |
+
folium.Marker(
|
143 |
+
location=[location['latitude'], location['longitude']],
|
144 |
+
popup=popup_content,
|
145 |
+
icon=icon
|
146 |
+
).add_to(mumbai_map)
|
147 |
+
|
148 |
+
title_html = """
|
149 |
+
<div style="font-size: 17px; font-weight: bold; text-align: left;">The best Restaurant to order food with best price and Quality</div>
|
150 |
+
"""
|
151 |
+
# Wrap the map in a Panel object
|
152 |
+
panel_map = pn.pane.HTML(title_html + mumbai_map._repr_html_(), width=800, height=600)
|
153 |
+
|
154 |
# Define the callback function for the radio button
|
155 |
def update_chart(event):
|
156 |
+
if event.new == 'Cuisine Type':
|
157 |
+
panel_layout[1:] = [panel_cuisine]
|
158 |
+
elif event.new == 'Rating Type':
|
159 |
+
panel_layout[1:]= [panel_rating]
|
160 |
+
elif event.new == 'Best Food Truck':
|
161 |
+
panel_layout[1:] = [panel_best_food_truck]
|
162 |
+
elif event.new == 'Top 10 Seafood':
|
163 |
+
panel_layout[1:] = [panel_top_seafood]
|
164 |
+
elif event.new == 'Highest Rated':
|
165 |
+
# Filter the DataFrame for highest rated restaurants
|
166 |
+
highest_rated = zomato_df[zomato_df['RATING'] >= 4.7]
|
167 |
+
|
168 |
+
# Create the bar plot using hvplot
|
169 |
+
bar_plot_highest_rated = highest_rated.hvplot.bar(
|
170 |
+
x='NAME',
|
171 |
+
y='PRICE',
|
172 |
+
color='#E10F14',
|
173 |
+
title='Highest Rated Restaurants in Mumbai: Price vs. Name',
|
174 |
+
xlabel='Restaurant Name',
|
175 |
+
ylabel='Price',
|
176 |
+
hover_cols=['RATING', 'REGION', 'CUSINE_CATEGORY'],
|
177 |
+
rot=90,
|
178 |
+
width=900,
|
179 |
+
height=500
|
180 |
+
)
|
181 |
+
|
182 |
+
# Wrap the bar plot in a Panel object
|
183 |
+
panel_highest_rated = pn.panel(bar_plot_highest_rated)
|
184 |
+
panel_layout[1:] = [panel_highest_rated]
|
185 |
+
elif event.new == 'Top Avg Price':
|
186 |
+
# Filter the DataFrame for ratings greater than or equal to 4.5
|
187 |
+
filtered_df = zomato_df[zomato_df['RATING'] >= 4.5]
|
188 |
+
|
189 |
+
# Calculate the mean price for each combination of 'REGION' and 'CUSINE TYPE'
|
190 |
+
highest_rated_price_df = filtered_df.groupby(['REGION', 'CUSINE TYPE'])['PRICE'].mean().reset_index()
|
191 |
+
|
192 |
+
# Sort the DataFrame by 'REGION' in alphabetical order
|
193 |
+
highest_rated_price_df = highest_rated_price_df.sort_values('REGION')
|
194 |
+
|
195 |
+
# Create a scatter plot with rotated labels and star marker
|
196 |
+
scatter_plot_top_avg_price = highest_rated_price_df.hvplot.scatter(
|
197 |
+
x='REGION',
|
198 |
+
y='PRICE',
|
199 |
+
c='CUSINE TYPE',
|
200 |
+
cmap='Category10',
|
201 |
+
title='Avg Price Distribution of High-rated restaurants for each Cuisine Type',
|
202 |
+
size=100, # Increase the marker size
|
203 |
+
rot=90,
|
204 |
+
width=900,
|
205 |
+
height=500,
|
206 |
+
marker='*',
|
207 |
+
)
|
208 |
+
|
209 |
+
# Create a Panel object with the scatter plot
|
210 |
+
panel_top_avg_price = pn.panel(scatter_plot_top_avg_price)
|
211 |
+
panel_layout[1:] = [panel_top_avg_price]
|
212 |
+
elif event.new == 'Chinese Resto':
|
213 |
+
zomato_df_cleaned = zomato_df.dropna(subset=['CUSINE_CATEGORY'])
|
214 |
+
chinese_df = zomato_df_cleaned[zomato_df_cleaned['CUSINE_CATEGORY'].str.contains('Chinese')]
|
215 |
+
chinese_rest_df = chinese_df.groupby(by='REGION').agg({'NAME': 'count', 'PRICE': 'mean'}).rename(columns={'NAME': 'COUNT OF RESTAURANTS'}).reset_index()
|
216 |
+
chinese_rest_df = chinese_rest_df.sort_values('COUNT OF RESTAURANTS', ascending=False).head(25)
|
217 |
+
bar_plot = chinese_rest_df.hvplot.bar(
|
218 |
+
x='REGION',
|
219 |
+
y='COUNT OF RESTAURANTS',
|
220 |
+
color='#E10F14', # Set the color to red
|
221 |
+
title='No. of Chinese Restaurants by Places',
|
222 |
+
xlabel='Region',
|
223 |
+
ylabel='Count of Restaurants',
|
224 |
+
rot=90,
|
225 |
+
height=500,
|
226 |
+
width=900
|
227 |
+
)
|
228 |
+
layout = pn.Column(bar_plot)
|
229 |
+
panel_layout[1:] = [bar_plot]
|
230 |
+
elif event.new == 'Price vs Rating':
|
231 |
+
# Calculate the mean price and rating for each cuisine type
|
232 |
+
price_rating_df = zomato_df.groupby(['CUSINE TYPE', 'RATING'])['PRICE'].mean().reset_index()
|
233 |
+
hvplot_price_rating = price_rating_df.hvplot.line(
|
234 |
+
x='RATING',
|
235 |
+
y='PRICE',
|
236 |
+
by='CUSINE TYPE',
|
237 |
+
title='Price vs Rating by Cuisine Type',
|
238 |
+
xlabel='Rating',
|
239 |
+
ylabel='Price',
|
240 |
+
width=900,
|
241 |
+
height=500,
|
242 |
+
legend='bottom' # Set the position of the legend to 'bottom'
|
243 |
+
)
|
244 |
+
|
245 |
+
# Set the number of legend columns
|
246 |
+
hvplot_price_rating.opts(legend_cols=6) # Adjust the value to your desired maximum number of legend items per row
|
247 |
+
|
248 |
+
# Wrap the Hvplot plot in a Panel object
|
249 |
+
panel_price_vs_rating = pn.panel(hvplot_price_rating)
|
250 |
+
panel_layout[1:] = [panel_price_vs_rating]
|
251 |
+
elif event.new == 'Region vs Price':
|
252 |
+
region_price_df = zomato_df.groupby(['REGION'])['PRICE'].mean().reset_index()
|
253 |
+
scatter_plot = region_price_df.hvplot.scatter(
|
254 |
+
x='REGION',
|
255 |
+
y='PRICE',
|
256 |
+
cmap='Category10',
|
257 |
+
title='Relation between Region and Price',
|
258 |
+
size=100, # Increase the marker size
|
259 |
+
rot=90,
|
260 |
+
width=900,
|
261 |
+
height=600,
|
262 |
+
marker='*',
|
263 |
+
color='red'
|
264 |
+
)
|
265 |
+
panel_region_vs_price = pn.Column(scatter_plot)
|
266 |
+
panel_layout[1:] = [panel_region_vs_price]
|
267 |
+
elif event.new == 'Map':
|
268 |
+
panel_layout[1:] = [panel_map]
|
269 |
|
270 |
yaxis_radio.param.watch(update_chart, 'value')
|
271 |
|
272 |
# Display the initial chart
|
273 |
+
panel_layout.append(panel_cuisine)
|
274 |
|
275 |
# Display the Panel layout
|
276 |
panel_layout
|
|
|
280 |
|
281 |
# Layout using Template
|
282 |
template = pn.template.FastListTemplate(
|
283 |
+
title='Zomato Mumbai Dashboard',
|
284 |
sidebar=[
|
285 |
+
pn.pane.PNG('zomato.png', sizing_mode='scale_both'),
|
286 |
+
pn.pane.Markdown("# Performing Exploratory Data Analysis"),
|
287 |
+
pn.pane.Markdown("1. How many restaurants are in Mumbai for each type of cuisine?"),
|
288 |
+
pn.pane.Markdown("2. What are the percentage of restaurants by Rating Type in Mumbai?"),
|
289 |
+
pn.pane.Markdown("3. Which are the Top 10 highest rated Seafood Restaurant in Mumbai?"),
|
290 |
+
pn.pane.Markdown("4. Which is the best Food Truck in Mumbai?"),
|
291 |
+
pn.pane.Markdown("5. Which places have the highest rated restaurant for each Cuisine Type in Mumbai?"),
|
292 |
+
pn.pane.Markdown("6. What is the Avg Price Distibution of highest rated restaurant for each Cuisine Type in Mumbai?"),
|
293 |
+
pn.pane.Markdown("7. Which areas have a large number of Chinese Restaurant Market?"),
|
294 |
+
pn.pane.Markdown("8. Is there a relation between Price and Rating by each Cuisine Type?"),
|
295 |
+
pn.pane.Markdown("9. Is there a relation between Region and Price?"),
|
296 |
+
pn.pane.Markdown("10. Can we map the best restraunt with high quality food?"),
|
297 |
],
|
298 |
main = [pn.Row(pn.Column(dashboard)),
|
|
|
299 |
pn.Row(pn.pane.Markdown("Designed and Developed with ❤️ by Chitranshu Nagdawane © 2023"))
|
300 |
],
|
301 |
+
accent_base_color="#E10F14",
|
302 |
+
header_background="#E10F14"
|
303 |
)
|
304 |
|
305 |
template.servable()
|
|
|
|
|
|
|
|