20
20
'Level 3' : ['Task 1' , 'Task 2' , 'Task 3' ]
21
21
}
22
22
23
+ #read in data
24
+ @st .cache_data
25
+ def get_data ():
26
+ df = pd .read_csv ('./data/data.csv' )
27
+ return df
28
+
23
29
# Create the Streamlit web app
24
30
def main ():
25
31
st .set_page_config (page_title = "Zomato Data Analysis" , page_icon = "🥘" , layout = "wide" )
@@ -37,7 +43,7 @@ def main():
37
43
st .write ('---' )
38
44
39
45
st .markdown ('- Load the dataset and identify the number of rows and columns.' )
40
- df = pd . read_csv ( "./data/data.csv" )
46
+ df = get_data ( )
41
47
st .write (df .head ())
42
48
st .write (f"Number of rows: { df .shape [0 ]} " )
43
49
st .write (f"Number of columns: { df .shape [1 ]} " )
@@ -63,7 +69,7 @@ def main():
63
69
64
70
if selected_task == 'Task 2' and selected_level == 'Level 1' :
65
71
st .markdown ('### Task 2: Descriptive Analysis' )
66
- df = pd . read_csv ( "./data/data.csv" )
72
+ df = get_data ( )
67
73
st .markdown ('- Calculate basic statistical measures (mean, median, standard deviation, etc.) for numerical columns.' )
68
74
st .write (df .describe ())
69
75
@@ -95,7 +101,7 @@ def main():
95
101
st .write ('Top 10 Cities:' , top_cities )
96
102
97
103
if selected_task == 'Task 3' and selected_level == 'Level 1' :
98
- df = pd . read_csv ( "./data/data.csv" )
104
+ df = get_data ( )
99
105
st .markdown ("### Task 3: Geospatial Analysis" )
100
106
101
107
st .markdown ("- Visualize the locations of restaurants on a map using latitude and longitude information." )
@@ -123,7 +129,7 @@ def main():
123
129
if selected_task == 'Task 1' and selected_level == 'Level 2' :
124
130
st .markdown ("### Task 1: Table Booking and Online Delivery" )
125
131
126
- df = pd . read_csv ( "./data/data.csv" )
132
+ df = get_data ( )
127
133
128
134
st .markdown ("- Determine the percentage of restaurants that offer table booking" )
129
135
table_booking_percentage = df ['Has Table booking' ].value_counts (normalize = True ) * 100
@@ -184,7 +190,7 @@ def main():
184
190
if selected_task == 'Task 2' and selected_level == 'Level 2' :
185
191
st .markdown ("### Task 2: Price Range Analysis" )
186
192
187
- df = pd . read_csv ( "./data/data.csv" )
193
+ df = get_data ( )
188
194
189
195
st .markdown ("- Determine the most common price range among all the restaurants" )
190
196
most_common_price_range = df ['Price range' ].mode ()[0 ]
@@ -231,7 +237,7 @@ def main():
231
237
232
238
if selected_task == 'Task 3' and selected_level == 'Level 2' :
233
239
st .markdown ("### Task 3: Feature Engineering" )
234
- df2 = pd . read_csv ( "./data/data.csv" )
240
+ df2 = get_data ( )
235
241
st .write ('---' )
236
242
237
243
st .markdown ("- Extract additional features from the existing columns, such as the length of the restaurant name or address." )
@@ -284,7 +290,7 @@ def main():
284
290
st .write ('---' )
285
291
286
292
if selected_task == 'Task 1' and selected_level == 'Level 3' :
287
- df = pd . read_csv ( "./data/data.csv" )
293
+ df = get_data ( )
288
294
289
295
st .markdown ("### Task 1: Predictive Modelling" )
290
296
@@ -350,7 +356,7 @@ def main():
350
356
st .write ('---' )
351
357
352
358
if selected_task == 'Task 2' and selected_level == 'Level 3' :
353
- df = pd . read_csv ( "./data/data.csv" )
359
+ df = get_data ( )
354
360
355
361
le = LabelEncoder ()
356
362
df ['Cuisines' ] = le .fit_transform (df ['Cuisines' ])
@@ -402,8 +408,7 @@ def main():
402
408
403
409
404
410
if selected_task == 'Task 3' and selected_level == 'Level 3' :
405
- st .write ("Restaurant Ratings Analysis" )
406
- df = pd .read_csv ("./data/data.csv" )
411
+ df = get_data ()
407
412
408
413
st .write ("### Distribution of Aggregate Rating" )
409
414
st .plotly_chart (px .histogram (df , x = 'Aggregate rating' , nbins = 20 , title = 'Distribution of Aggregate Rating' ))
0 commit comments