File size: 2,921 Bytes
30b11c6 6498440 f144f21 30b11c6 f144f21 5251d02 f144f21 5251d02 6498440 f144f21 6498440 f144f21 6498440 f144f21 |
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 74 75 76 77 78 79 80 81 |
import streamlit as st
from PIL import Image
import os
st.title("Our History in Data")
# Set the global index path
global_index_path = "data/immaterial_index/figures_trends_R/results"
unseen_index_path = (
"data/immaterial_index/figures_trends_R/figures_unseen/results_unseen"
)
unseen_capita_index_path = (
"data/immaterial_index/figures_trends_R/figures_unseen/results_unseen/per_capita"
)
population_path = "data/population"
# Update image_paths using global_index_path
index_paths = {
"India": {
"global_index": f"{global_index_path}/india.png",
"unseen_index": f"{unseen_index_path}/india.png",
"unseen_index_capita": f"{unseen_capita_index_path}/india.png",
"population_index": f"{population_path}/Indian world.png",
},
"Japan": {
"global_index": f"{global_index_path}/japan.png",
"unseen_index": f"{unseen_index_path}/japan.png",
"unseen_index_capita": f"{unseen_capita_index_path}/Japan.png",
"population_index": f"{population_path}/Japan.png",
},
"France": {
"global_index": f"{global_index_path}/france.png",
"unseen_index": f"{unseen_index_path}/france.png",
"unseen_index_capita": f"{unseen_capita_index_path}/France.png",
"population_index": f"{population_path}/France.png",
},
"Italy": {
"global_index": f"{global_index_path}/italy.png",
"unseen_index": f"{unseen_index_path}/italy.png",
"unseen_index_capita": f"{unseen_capita_index_path}/Italy.png",
"population_index": f"{population_path}/Italy.png",
},
"Spain": {
"global_index": f"{global_index_path}/spain.png",
"unseen_index": f"{unseen_index_path}/spain.png",
"unseen_index_capita": f"{unseen_capita_index_path}/Spain.png",
"population_index": f"{population_path}/Spain.png",
},
}
# Get the region names (keys) from the index_paths dictionary
regions = list(index_paths.keys())
# Allow the user to select a region
selected_region = st.sidebar.selectbox("Region:", regions)
# Display the selected region's images vertically
if selected_region in index_paths:
for key, path in index_paths[selected_region].items():
if os.path.exists(path):
if key == "global_index":
st.subheader("Global Index")
elif key == "unseen_index":
st.subheader("Unsee-Species Index")
elif key == "unseen_index_capita":
st.subheader("Unsee-Species per capita Index")
elif key == "population_index":
st.subheader("")
st.image(Image.open(path), caption=key.capitalize(), use_column_width=True)
else:
st.write(f"File for {key.capitalize()} does not exist.")
# Add more information or charts specific to India here
else:
st.write("Please select India as the region from the sidebar on the left.")
|