import streamlit as st import pandas as pd from streamlit_folium import folium_static import folium import ast used_fields = ["classe_consommation_energie", "commentaires_ameliorations_recommandations", "nom_methode_dpe", "usr_diagnostiqueur_id", "numero_dpe", "secteur_activite", "annee_construction", "organisme_certificateur", "adresse_organisme_certificateur", "tv016_departement_departement", "long_lat", "address", "positif_negatif", "commune"] def _max_width_(): max_width_str = f"max-width: 1500px;" st.markdown( f""" """, unsafe_allow_html=True, ) # force screen width _max_width_() @st.cache def load_data(): return pd.read_csv("outlier_V2.csv", sep=",") st.header("DPE") # load data DPE = load_data() DPE = DPE[used_fields] # filter departement departe = st.sidebar.selectbox('Séléctionnez le département', DPE['tv016_departement_departement'].unique()) sub_DPE = DPE[DPE.tv016_departement_departement == departe] commune = st.sidebar.selectbox('Séléctionnez la commune', sub_DPE['commune'].unique()) sub_DPE = DPE[DPE.commune == commune].dropna() st.subheader("Selectionner des certificateurs") certificateur = st.multiselect("Organismes certificateurs", sub_DPE['organisme_certificateur'].unique(), []) if certificateur: sub_DPE = sub_DPE[sub_DPE.organisme_certificateur.isin(certificateur)] sub_DPE.long_lat = sub_DPE.long_lat.apply(ast.literal_eval) sub_DPE["address"] = sub_DPE.address.str.replace("nan ", "") if sub_DPE.shape[0]: # set the map center m = folium.Map(location=sub_DPE.long_lat.values[0], zoom_start=12) for index, row in sub_DPE.iterrows(): tooltip = row['address'] if row["positif_negatif"] == "sous_estimé": color = "green" else: color = "red" html = f"