|
|
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""" |
|
|
<style> |
|
|
.reportview-container .main .block-container{{ |
|
|
{max_width_str} |
|
|
}} |
|
|
</style> |
|
|
""", |
|
|
unsafe_allow_html=True, |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
_max_width_() |
|
|
|
|
|
|
|
|
@st.cache |
|
|
def load_data(): |
|
|
return pd.read_csv("outlier_V2.csv", sep=",") |
|
|
|
|
|
|
|
|
st.header("DPE") |
|
|
|
|
|
|
|
|
DPE = load_data() |
|
|
DPE = DPE[used_fields] |
|
|
|
|
|
|
|
|
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]: |
|
|
|
|
|
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"<h2>{row['address']}</h2><ul><li><b>Classe d'energie attribué: </b>{row['classe_consommation_energie']}</li><br>" \ |
|
|
f"<li><b style = 'color:{color}' >D'apres notre algorithme le DPE est {row['positif_negatif']}</b></li><br>" \ |
|
|
f"<li><b>Méthode utilisée: </b>{row['nom_methode_dpe']}</li><br>" \ |
|
|
f"<li><b>Secteur Activite: </b>{row['secteur_activite']}</li><br>" \ |
|
|
f"<li><b>Année de construction: </b>{int(row['annee_construction'])}</li><br>" \ |
|
|
f"<li><b>Commentaire: </b>{row['commentaires_ameliorations_recommandations']}</li><br>" \ |
|
|
f"<li><b>Organisme Certificateur: </b>{row['organisme_certificateur']} - {row['adresse_organisme_certificateur']}</li></ul>" |
|
|
|
|
|
iframe = folium.IFrame(html) |
|
|
popup = folium.Popup(iframe, |
|
|
min_width=500, |
|
|
max_width=700) |
|
|
|
|
|
folium.Marker( |
|
|
row['long_lat'], popup=popup, tooltip=tooltip, icon=folium.Icon(color=color), |
|
|
).add_to(m) |
|
|
|
|
|
|
|
|
folium_static(m, width=1400) |
|
|
|