File size: 3,315 Bytes
9d90623
c2aa26d
 
 
d778de8
9d90623
29d876f
 
8ef3c9d
c2aa26d
 
 
d778de8
c2aa26d
 
 
d778de8
 
8ef3c9d
c2aa26d
 
 
29d876f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ef3c9d
c2aa26d
 
8ef3c9d
c2aa26d
29d876f
 
 
c2aa26d
 
 
 
 
 
 
 
 
 
29d876f
 
 
 
 
 
c2aa26d
d778de8
 
8ef3c9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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,
    )


# force screen width
_max_width_()


@st.cache
def load_data():
    return pd.read_csv("outlier_V2.csv", sep=",")


st.header("Analyse des anomalies sur les 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"<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)

    # call to render Folium map in Streamlit
    folium_static(m, width=1400)