Chitranshu commited on
Commit
03a0fd1
·
0 Parent(s):

Duplicate from Chitranshu/Dashboard-Zomato

Browse files
Files changed (7) hide show
  1. .gitattributes +35 -0
  2. Dockerfile +16 -0
  3. README.md +11 -0
  4. app.py +305 -0
  5. requirements.txt +8 -0
  6. zomato.png +0 -0
  7. zomato_data.csv +0 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+ RUN python3 -m pip install --no-cache-dir --upgrade pip
7
+ RUN python3 -m pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["panel", "serve", "/code/app.py", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "*"]
12
+
13
+ RUN mkdir /.cache
14
+ RUN chmod 777 /.cache
15
+ RUN mkdir .chroma
16
+ RUN chmod 777 .chroma
README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Zomato-Dashboard
3
+ emoji: 📊
4
+ colorFrom: red
5
+ colorTo: red
6
+ sdk: docker
7
+ pinned: false
8
+ duplicated_from: Chitranshu/Dashboard-Zomato
9
+ ---
10
+
11
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
277
+ dashboard = panel_layout
278
+ import panel as pn
279
+ pn.extension() # Add this line to load the Panel extension
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()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ panel
2
+ jupyter
3
+ numpy
4
+ pandas
5
+ hvplot
6
+ bokeh
7
+ seaborn
8
+ folium
zomato.png ADDED
zomato_data.csv ADDED
The diff for this file is too large to render. See raw diff