Nicolas Pierson commited on
^^
Browse files
src/pages/1_Historical_Prices.py
CHANGED
|
@@ -70,22 +70,21 @@ async def _load_all_data_async_internal_communes():
|
|
| 70 |
communes_geojson_task = async_load_geojson_from_s3(
|
| 71 |
"processed/referentiel/communes.geojson"
|
| 72 |
)
|
| 73 |
-
|
| 74 |
return await asyncio.gather(
|
| 75 |
communes_df_task,
|
| 76 |
communes_geojson_task,
|
|
|
|
| 77 |
)
|
| 78 |
|
| 79 |
|
| 80 |
@st.cache_resource
|
| 81 |
def load_all_data_sync_wrapper_departements():
|
| 82 |
-
# This synchronous wrapper runs the async data loading
|
| 83 |
return asyncio.run(_load_all_data_async_internal_departements())
|
| 84 |
|
| 85 |
|
| 86 |
@st.cache_resource
|
| 87 |
def load_all_data_sync_wrapper_communes():
|
| 88 |
-
# This synchronous wrapper runs the async data loading
|
| 89 |
return asyncio.run(_load_all_data_async_internal_communes())
|
| 90 |
|
| 91 |
|
|
@@ -237,7 +236,6 @@ st.write(
|
|
| 237 |
)
|
| 238 |
|
| 239 |
with st.spinner("Loading data and preparing maps..."):
|
| 240 |
-
# Call the synchronous wrapper function
|
| 241 |
(
|
| 242 |
dataset_departements_housing_prices,
|
| 243 |
departements_geojson,
|
|
@@ -259,10 +257,10 @@ st.write(
|
|
| 259 |
st.subheader("Select a Department to View Commune Prices")
|
| 260 |
|
| 261 |
with st.spinner("Loading data and preparing maps..."):
|
| 262 |
-
# Call the synchronous wrapper function
|
| 263 |
(
|
| 264 |
dataset_housing_prices,
|
| 265 |
communes_geojson,
|
|
|
|
| 266 |
) = load_all_data_sync_wrapper_communes()
|
| 267 |
|
| 268 |
min_global_commune_prixm2moyen = dataset_housing_prices[
|
|
@@ -272,7 +270,8 @@ with st.spinner("Loading data and preparing maps..."):
|
|
| 272 |
|
| 273 |
selected_departement = st.selectbox(
|
| 274 |
"Select a Department",
|
| 275 |
-
options=
|
|
|
|
| 276 |
)
|
| 277 |
|
| 278 |
fig_department = display_choropleth_map_for_department(
|
|
|
|
| 70 |
communes_geojson_task = async_load_geojson_from_s3(
|
| 71 |
"processed/referentiel/communes.geojson"
|
| 72 |
)
|
| 73 |
+
insee_task = async_load_file_s3("processed/referentiel/ref_espace_communes.csv")
|
| 74 |
return await asyncio.gather(
|
| 75 |
communes_df_task,
|
| 76 |
communes_geojson_task,
|
| 77 |
+
insee_task
|
| 78 |
)
|
| 79 |
|
| 80 |
|
| 81 |
@st.cache_resource
|
| 82 |
def load_all_data_sync_wrapper_departements():
|
|
|
|
| 83 |
return asyncio.run(_load_all_data_async_internal_departements())
|
| 84 |
|
| 85 |
|
| 86 |
@st.cache_resource
|
| 87 |
def load_all_data_sync_wrapper_communes():
|
|
|
|
| 88 |
return asyncio.run(_load_all_data_async_internal_communes())
|
| 89 |
|
| 90 |
|
|
|
|
| 236 |
)
|
| 237 |
|
| 238 |
with st.spinner("Loading data and preparing maps..."):
|
|
|
|
| 239 |
(
|
| 240 |
dataset_departements_housing_prices,
|
| 241 |
departements_geojson,
|
|
|
|
| 257 |
st.subheader("Select a Department to View Commune Prices")
|
| 258 |
|
| 259 |
with st.spinner("Loading data and preparing maps..."):
|
|
|
|
| 260 |
(
|
| 261 |
dataset_housing_prices,
|
| 262 |
communes_geojson,
|
| 263 |
+
insee_df,
|
| 264 |
) = load_all_data_sync_wrapper_communes()
|
| 265 |
|
| 266 |
min_global_commune_prixm2moyen = dataset_housing_prices[
|
|
|
|
| 270 |
|
| 271 |
selected_departement = st.selectbox(
|
| 272 |
"Select a Department",
|
| 273 |
+
options=insee_df["code_departement"].unique().sort(),
|
| 274 |
+
format_func=lambda x: insee_df[insee_df["code_departement"] == x]["nom_departement"].values[0] if x in insee_df["code_departement"].values else x
|
| 275 |
)
|
| 276 |
|
| 277 |
fig_department = display_choropleth_map_for_department(
|