Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from bs4 import BeautifulSoup
|
|
3 |
import pandas as pd
|
4 |
import plotly.graph_objects as go
|
5 |
import streamlit as st
|
6 |
-
from geopy.geocoders import Nominatim
|
7 |
|
8 |
# 設定應用標題
|
9 |
st.title("餐廳資料抓取與分析")
|
@@ -19,7 +19,7 @@ urls = urls_df['網址'].tolist()
|
|
19 |
df_list = []
|
20 |
|
21 |
# 初始化地理定位器
|
22 |
-
geolocator = Nominatim(user_agent="restaurant_locator")
|
23 |
|
24 |
# 迭代每個網址並抓取資料
|
25 |
for url in urls:
|
@@ -80,10 +80,9 @@ fig_pie.update_layout(title='每個區的商家數量比例')
|
|
80 |
if st.button('顯示每個區的商家數量比例圓餅圖'):
|
81 |
st.plotly_chart(fig_pie)
|
82 |
|
83 |
-
#
|
84 |
-
st.
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
st.map(df_map[['Latitude', 'Longitude']])
|
|
|
3 |
import pandas as pd
|
4 |
import plotly.graph_objects as go
|
5 |
import streamlit as st
|
6 |
+
from geopy.geocoders import Nominatim
|
7 |
|
8 |
# 設定應用標題
|
9 |
st.title("餐廳資料抓取與分析")
|
|
|
19 |
df_list = []
|
20 |
|
21 |
# 初始化地理定位器
|
22 |
+
geolocator = Nominatim(user_agent="restaurant_locator")
|
23 |
|
24 |
# 迭代每個網址並抓取資料
|
25 |
for url in urls:
|
|
|
80 |
if st.button('顯示每個區的商家數量比例圓餅圖'):
|
81 |
st.plotly_chart(fig_pie)
|
82 |
|
83 |
+
# 顯示地圖按鈕
|
84 |
+
if st.button('顯示餐廳地圖'):
|
85 |
+
st.subheader("餐廳地圖")
|
86 |
+
# Drop rows with missing coordinates
|
87 |
+
df_map = df.dropna(subset=['Latitude', 'Longitude'])
|
88 |
+
st.map(df_map[['Latitude', 'Longitude']])
|
|