Replicate the app from the image.
Drop files here
or click to upload
import streamlit as st
import pandas as pd
import plotly.express as px
# Set page config
st.set_page_config(page_title="Population Density", layout="wide")
# Title
st.title("Population Density")
# Load sample world population data
@st.cache_data
def load_data():
# Create sample data for demonstration
df = pd.DataFrame({
'country': ['China', 'India', 'USA', 'Indonesia', 'Pakistan'],
'population_density': [153, 464, 36, 151, 287]
})
return df
data = load_data()
# Create choropleth map
fig = px.choropleth(
data,
locations='country',
locationmode='country names',
color='population_density',
hover_name='country',
color_continuous_scale='Viridis',
title='World Map',
height=600
)
# Update layout
fig.update_layout(
margin=dict(l=0, r=0, t=30, b=0),
coloraxis_colorbar_title='Population Density<br>(people per km²)'
)
# Display the map
st.plotly_chart(fig, use_container_width=True)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?