File size: 3,060 Bytes
4ab3c1e
1f60fbc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4ab3c1e
 
 
144723f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f60fbc
 
 
c091de5
1f60fbc
 
ead695a
1f60fbc
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import csv
import base64

# Define the state populations and family sizes
state_data = {
    'California': {'population': 39538223, 'family_size': 3.3},
    'Texas': {'population': 29145505, 'family_size': 3.4},
    'Florida': {'population': 21538187, 'family_size': 3.0},
    'New York': {'population': 19849399, 'family_size': 3.1},
    'Minnesota': {'population': 5700671, 'family_size': 2.5},
    'Wisconsin': {'population': 5897473, 'family_size': 2.6},
}

# Define the state spending data
spending_data = {
    'California': {'education': 2500, 'healthcare': 3000, 'transportation': 1500},
    'Texas': {'education': 2000, 'healthcare': 2500, 'transportation': 1000},
    'Florida': {'education': 1500, 'healthcare': 2000, 'transportation': 750},
    'New York': {'education': 3000, 'healthcare': 3500, 'transportation': 2000},
    'Minnesota': {'education': 1000, 'healthcare': 1500, 'transportation': 500},
    'Wisconsin': {'education': 1250, 'healthcare': 1750, 'transportation': 750},
}

# Define the emoji icons
POPULATION_ICON = 'πŸ‘₯'
FAMILY_SIZE_ICON = 'πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦'
EDUCATION_ICON = '🏫'
HEALTHCARE_ICON = 'πŸ₯'
TRANSPORTATION_ICON = 'πŸš—'

def main():
    st.title('State Comparison')

    # Consolidate the state data and spending data into a list of dictionaries
    state_list = []
    for state, data in state_data.items():
        state_dict = {
            'state': state,
            'population': data['population'],
            'family_size': data['family_size'],
            'education_spending': spending_data[state]['education'],
            'healthcare_spending': spending_data[state]['healthcare'],
            'transportation_spending': spending_data[state]['transportation']
        }
        state_list.append(state_dict)

    # Save the data to a CSV file and provide a download link
    with open('state_data.csv', mode='w', newline='') as file:
        writer = csv.DictWriter(file, fieldnames=['state', 'population', 'family_size', 'education_spending', 'healthcare_spending', 'transportation_spending'])
        writer.writeheader()
        for state in state_list:
            writer.writerow(state)
    with open('state_data.csv', mode='rb') as file:
        b64 = base64.b64encode(file.read()).decode('utf-8')
    st.markdown(f'<a href="data:file/csv;base64,{b64}" download="state_data.csv">Download State Data CSV File</a>', unsafe_allow_html=True)

    # Display state populations and family sizes
    st.header('Population and Family Size')
    for state, data in state_data.items():
        st.subheader(f'{POPULATION_ICON} {state}')
    st.write(f'Population: {data["population"]}')
    st.write(f'Family Size: {data["family_size"]}')

# Display state spending data
st.header('State Spending')
for state, data in spending_data.items():
    st.subheader(state)
    st.write(f'{EDUCATION_ICON} Education: {data["education"]}')
    st.write(f'{HEALTHCARE_ICON} Healthcare: {data["healthcare"]}')
    st.write(f'{TRANSPORTATION_ICON} Transportation: {data["transportation"]}')