Update app.py
Browse files
app.py
CHANGED
@@ -4,28 +4,23 @@ import plotly.express as px
|
|
4 |
|
5 |
@st.cache
|
6 |
def load_usa_map():
|
7 |
-
return gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
|
8 |
|
9 |
def generate_speech_textarea(text):
|
10 |
st.markdown(f'<p id="speech" hidden>{text}</p><button onclick="speechSynthesis.speak(new SpeechSynthesisUtterance(document.getElementById(\'speech\').textContent))">🔊 Speak</button>', unsafe_allow_html=True)
|
11 |
|
12 |
state_data = {
|
13 |
-
'MN': {'name': 'Minnesota', 'trivia': '1️⃣ Home to over 10,000 lakes
|
14 |
-
'CA': {'name': 'California', 'trivia': '1️⃣ Known for Hollywood
|
15 |
-
|
16 |
-
'FL': {'name': 'Florida', 'trivia': '1️⃣ Home to Walt Disney World\n2️⃣ Florida Keys', 'largest_company': 'World Fuel Services', 'revenue': 27.0},
|
17 |
-
'TX': {'name': 'Texas', 'trivia': '1️⃣ Birthplace of Texas Country Music\n2️⃣ Tex-Mex Cuisine', 'largest_company': 'ExxonMobil', 'revenue': 265.7},
|
18 |
-
'NY': {'name': 'New York', 'trivia': '1️⃣ Home of Wall Street\n2️⃣ The Big Apple', 'largest_company': 'JPMorgan Chase', 'revenue': 119.5},
|
19 |
-
'NV': {'name': 'Nevada', 'trivia': '1️⃣ Las Vegas Strip\n2️⃣ Area 51', 'largest_company': 'Las Vegas Sands', 'revenue': 13.7},
|
20 |
-
'TN': {'name': 'Tennessee', 'trivia': '1️⃣ Home of Country Music\n2️⃣ Tennessee Whiskey', 'largest_company': 'FedEx', 'revenue': 69.2},
|
21 |
-
'HI': {'name': 'Hawaii', 'trivia': '1️⃣ Aloha Spirit\n2️⃣ Surfing Paradise', 'largest_company': 'Hawaiian Electric Industries', 'revenue': 2.9},
|
22 |
-
'SD': {'name': 'South Dakota', 'trivia': '1️⃣ Mount Rushmore\n2️⃣ Badlands National Park', 'largest_company': 'Sanford Health', 'revenue': 4.5}
|
23 |
}
|
24 |
|
25 |
usa = load_usa_map()
|
|
|
|
|
26 |
selected_state = st.selectbox("📍 Choose a state:", list(state_data.keys()), format_func=lambda x: f"{state_data[x]['name']} ({x})")
|
27 |
|
28 |
-
state_geom_df = usa[usa
|
29 |
if not state_geom_df.empty:
|
30 |
geom = state_geom_df.geometry.iloc[0]
|
31 |
fig = px.choropleth(usa, geojson=usa.geometry, locations=usa.index, scope="usa")
|
|
|
4 |
|
5 |
@st.cache
|
6 |
def load_usa_map():
|
7 |
+
return gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
|
8 |
|
9 |
def generate_speech_textarea(text):
|
10 |
st.markdown(f'<p id="speech" hidden>{text}</p><button onclick="speechSynthesis.speak(new SpeechSynthesisUtterance(document.getElementById(\'speech\').textContent))">🔊 Speak</button>', unsafe_allow_html=True)
|
11 |
|
12 |
state_data = {
|
13 |
+
'US-MN': {'name': 'Minnesota', 'trivia': '1️⃣ Home to over 10,000 lakes 🌊\n2️⃣ Boundary Waters Canoe Area 🛶', 'largest_company': 'UnitedHealth Group', 'revenue': 257.1},
|
14 |
+
'US-CA': {'name': 'California', 'trivia': '1️⃣ Known for Hollywood 🎬\n2️⃣ Golden Gate Bridge 🌉', 'largest_company': 'Apple', 'revenue': 365.8},
|
15 |
+
# ... (your other states)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
|
18 |
usa = load_usa_map()
|
19 |
+
usa = usa[usa['iso_a2'].str.startswith('US', na=False)] # Filter only US states
|
20 |
+
|
21 |
selected_state = st.selectbox("📍 Choose a state:", list(state_data.keys()), format_func=lambda x: f"{state_data[x]['name']} ({x})")
|
22 |
|
23 |
+
state_geom_df = usa[usa['iso_a2'] == selected_state]
|
24 |
if not state_geom_df.empty:
|
25 |
geom = state_geom_df.geometry.iloc[0]
|
26 |
fig = px.choropleth(usa, geojson=usa.geometry, locations=usa.index, scope="usa")
|