File size: 2,662 Bytes
81b6f31
9dd240d
 
 
81b6f31
9dd240d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81b6f31
9dd240d
 
81b6f31
9dd240d
 
81b6f31
9dd240d
 
81b6f31
9dd240d
 
 
 
81b6f31
9dd240d
 
 
 
 
 
 
81b6f31
9dd240d
 
81b6f31
9dd240d
 
 
81b6f31
9dd240d
 
 
 
81b6f31
9dd240d
 
 
 
81b6f31
9dd240d
 
81b6f31
 
9dd240d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import streamlit as st
import pandas as pd
import folium
from streamlit_folium import st_folium

# Data for each state
data = {
    "MA": {
        "Companies": [
            {"Name": "Amazon (MA)", "Employees": 7000, "City": "Boston"},
            {"Name": "MIT (Cambridge, MA)", "Employees": 6300, "City": "Cambridge"},
            {"Name": "Fidelity Investments (Boston, MA)", "Employees": 5000, "City": "Boston"},
            {"Name": "State Street Corporation (Boston, MA)", "Employees": 4000, "City": "Boston"},
            {"Name": "Partners Healthcare System (Boston, MA)", "Employees": 3500, "City": "Boston"}
        ],
        "Cities": [
            {"Name": "Boston", "Population": 700000, "Income": 75000, "Latitude": 42.3601, "Longitude": -71.0589},
            {"Name": "Cambridge", "Population": 120000, "Income": 85000, "Latitude": 42.3736, "Longitude": -71.1097},
            # Add other cities...
        ],
        "Hospitals": [
            {"Name": "Massachusetts General Hospital", "Beds": 1000, "City": "Boston"},
            # Add other hospitals...
        ]
    },
    # Add data for CA and WA...
}

# Streamlit page configuration
st.set_page_config(page_title="State Data", layout="wide")

# Main title
st.title("State Information Dashboard")

# Select a state
selected_state = st.selectbox("Select a State:", ["MA", "CA", "WA"])

# Process selected state data
companies_df = pd.DataFrame(data[selected_state]["Companies"])
cities_df = pd.DataFrame(data[selected_state]["Cities"])
hospitals_df = pd.DataFrame(data[selected_state]["Hospitals"])

# Display DataFrames
st.write("Companies:")
st.dataframe(companies_df)
st.write("Cities:")
st.dataframe(cities_df)
st.write("Hospitals:")
st.dataframe(hospitals_df)

# Create a Folium map for the selected state
m = folium.Map(location=[cities_df["Latitude"].mean(), cities_df["Longitude"].mean()], zoom_start=7)

# Add markers for cities, companies, and hospitals
for _, city in cities_df.iterrows():
    folium.Marker([city["Latitude"], city["Longitude"]], tooltip=f"{city['Name']}").add_to(m)

for _, company in companies_df.iterrows():
    # Find the city's coordinates
    city = cities_df[cities_df["Name"] == company["City"]].iloc[0]
    folium.Marker([city["Latitude"], city["Longitude"]], tooltip=f"{company['Name']}").add_to(m)

for _, hospital in hospitals_df.iterrows():
    # Find the city's coordinates
    city = cities_df[cities_df["Name"] == hospital["City"]].iloc[0]
    folium.Marker([city["Latitude"], city["Longitude"]], tooltip=f"{hospital['Name']}").add_to(m)

# Display the map
st_folium(m, width=700, height=500)

# Footer
st.caption("Data source: User provided")