gay people by state
To upload files, please first save the app
import streamlit as st
import pandas as pd
import plotly.express as px
st.title("LGBT Population by State")
# Create sample data for LGBT population by state (2021 estimates)
data = {
'State': [
'California', 'New York', 'Florida', 'Texas', 'Washington',
'Massachusetts', 'Illinois', 'Oregon', 'New Jersey', 'Colorado',
'Georgia', 'Pennsylvania', 'Michigan', 'Virginia', 'Arizona',
'Minnesota', 'Ohio', 'North Carolina', 'Nevada', 'Wisconsin',
'Maryland', 'Connecticut', 'Hawaii', 'New Mexico', 'Rhode Island',
'Delaware', 'New Hampshire', 'Vermont', 'Maine', 'Idaho',
'Montana', 'Alaska', 'Wyoming', 'North Dakota', 'South Dakota',
'Iowa', 'Nebraska', 'Kansas', 'Oklahoma', 'Arkansas',
'Mississippi', 'Alabama', 'Louisiana', 'Tennessee', 'Kentucky',
'West Virginia', 'Missouri', 'Indiana', 'South Carolina', 'Utah'
],
'LGBT_Percentage': [
5.3, 5.1, 4.6, 4.1, 5.2,
5.4, 4.3, 5.6, 4.1, 4.6,
4.5, 4.1, 4.2, 4.0, 4.5,
4.1, 4.0, 4.0, 5.3, 4.0,
4.2, 4.4, 4.6, 4.5, 4.5,
4.5, 4.1, 5.2, 4.0, 3.3,
3.5, 4.2, 3.3, 3.0, 3.0,
3.6, 3.4, 3.5, 3.8, 3.3,
3.1, 3.1, 3.9, 3.5, 3.4,
3.1, 3.8, 3.9, 3.5, 3.7
]
}
df = pd.DataFrame(data)
# Create choropleth map
fig = px.choropleth(
df,
locations='State',
locationmode='USA-states',
color='LGBT_Percentage',
scope='usa',
color_continuous_scale='Viridis',
title='Estimated LGBT Population Percentage by State (2021)',
labels={'LGBT_Percentage': 'LGBT Population (%)'}
)
# Display the map
st.plotly_chart(fig, use_container_width=True)
# Display the data in a table
st.subheader("State-by-State LGBT Population Percentages")
sorted_df = df.sort_values('LGBT_Percentage', ascending=False)
st.table(sorted_df)
st.caption("Note: Data shown are estimates based on various surveys and studies. Actual percentages may vary.")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?