Py.Cafe

alexandre.jewell/

streamlit-on-pycafe

Streamlit on Pycafe: Interactive App Samples

DocsPricing
  • assets/
  • data/
  • action_areas.geojson
  • app.py
  • requirements.txt
  • utils.py
app.py
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import streamlit as st
import pandas as pd
import numpy as np
import geopandas as gpd

from shapely.geometry import Point

st.title('MEP Reporting Template')

st.image('assets/Zones.png')

st.header('Data files')

buildings = pd.read_csv('data/buildings.csv')
systems = pd.read_csv('data/systems.csv')

with st.expander('Buildings data'):
    st.dataframe(buildings)

with st.expander('Systems data'):
    st.dataframe(systems)

geodataframe = None

with st.expander('Action areas'):
    uploaded_file = st.file_uploader('Upload your action areas:')
    if uploaded_file is not None: 

        # Can be used wherever a "file-like" object is accepted:
        geodataframe = gpd.read_file(uploaded_file)
        geodataframe.columns = [col.lower() for col in geodataframe.columns]
        st.dataframe(geodataframe.drop(columns='geometry'))

st.header('Target scenarios')

st.subheader('Renovation')

st.markdown('Add here the default assumptions used for modelling the renovation of your building stocks πŸ‘‡')

renovation_df = pd.DataFrame(data = {'criteria':['Start year', 'End year', 'Interval', 'Renovation rate (%)'], 'values':[2025,2045,5,3]})
ratio_df = pd.DataFrame(data = {'Building sector':['Residential','Commercial and traffic', 'Industry and production', 'Public buildings'], 'reduction ratio':[35,37, 29, 33]})
col1, col2 = st.columns(2)

with col1:
    st.markdown('**Renovation parameters**')
    renovation_edited = st.data_editor(
        renovation_df,
        column_config={
            'values': st.column_config.NumberColumn(
                "Values",
            )
        },
        hide_index = True
    )

with col2:
    st.markdown('**Reduction ratios**')
    ratio_edited = st.data_editor(
        ratio_df,
        column_config={
            'reduction ratio': st.column_config.NumberColumn(
                "Reduction ratio",
                min_value=0,
                max_value=100,
                format="%.2f%%"
            )
        },
        hide_index = True
    )

st.image('assets/Renovation.png')

st.subheader('Heating system substitution')

st.markdown('Define the parameters linked to your action areas πŸ‘‡')

needed_cols = ['name','system group', 'system type', 'geothermal', 'water body', 'wood', 'waste heat', 'biogas', 'start year', 'end year']

if geodataframe is not None:
    for col in needed_cols:
        if col.lower() not in geodataframe.columns:
            geodataframe[col.lower()] = np.nan

    geodataframe_edited = st.data_editor(
        geodataframe.drop(columns='geometry')[needed_cols],
        column_config={
            "system group": st.column_config.SelectboxColumn(
                "Group of systems",
                help = "The group of systems of the zone",
                options = [
                    "District heating network",
                    "Decentralized heating"
                ],
                required = True
            )
        },
        hide_index=True,
    )

    geodataframe_new = gpd.GeoDataFrame(geodataframe_edited, geometry = geodataframe['geometry'])
    geojson = geodataframe_new.to_json()
    
    st.download_button(
        label = "Dowload the zones", 
        data = geojson,
        file_name = "action_areas.geojson",
        mime="application/geo+json")
    
    # buildings_gdf = gpd.GeoDataFrame(buildings, geometry = gpd.points_from_xy(buildings["coordinate x"], buildings["coordinate y"]), crs = "EPSG:4326")
    


else:
    st.error('Action areas not uploaded. Please upload the action areas.', icon = "πŸ’‘")


st.markdown('**Heating system substitution**')
st.image('assets/Heating_system_substitution.png')

st.markdown('**District heating zones deployment**')
st.image('assets/District_heating_zones_deployment.png')

st.markdown('**Heat supply evolution**')
st.image('assets/Heat_supply_evolution.png')

st.markdown('**Final energy demand evolution**')
st.image('assets/Final_energy_demand_evolution.png')

st.markdown('**Greenhouse gas emissions evolution**')
st.image('assets/GHG_emissions_evolution.png')
app.py
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import streamlit as st
import pandas as pd
import numpy as np
import geopandas as gpd

from shapely.geometry import Point

st.title('MEP Reporting Template')

st.image('assets/Zones.png')

st.header('Data files')

buildings = pd.read_csv('data/buildings.csv')
systems = pd.read_csv('data/systems.csv')

with st.expander('Buildings data'):
    st.dataframe(buildings)

with st.expander('Systems data'):
    st.dataframe(systems)

geodataframe = None

with st.expander('Action areas'):
    uploaded_file = st.file_uploader('Upload your action areas:')
    if uploaded_file is not None: 

        # Can be used wherever a "file-like" object is accepted:
        geodataframe = gpd.read_file(uploaded_file)
        geodataframe.columns = [col.lower() for col in geodataframe.columns]
        st.dataframe(geodataframe.drop(columns='geometry'))

st.header('Target scenarios')

st.subheader('Renovation')

st.markdown('Add here the default assumptions used for modelling the renovation of your building stocks πŸ‘‡')

renovation_df = pd.DataFrame(data = {'criteria':['Start year', 'End year', 'Interval', 'Renovation rate (%)'], 'values':[2025,2045,5,3]})
ratio_df = pd.DataFrame(data = {'Building sector':['Residential','Commercial and traffic', 'Industry and production', 'Public buildings'], 'reduction ratio':[35,37, 29, 33]})
col1, col2 = st.columns(2)

with col1:
    st.markdown('**Renovation parameters**')
    renovation_edited = st.data_editor(
        renovation_df,
        column_config={
            'values': st.column_config.NumberColumn(
                "Values",
            )
        },
        hide_index = True
    )

with col2:
    st.markdown('**Reduction ratios**')
    ratio_edited = st.data_editor(
        ratio_df,
        column_config={
            'reduction ratio': st.column_config.NumberColumn(
                "Reduction ratio",
                min_value=0,
                max_value=100,
                format="%.2f%%"
            )
        },
        hide_index = True
    )

st.image('assets/Renovation.png')

st.subheader('Heating system substitution')

st.markdown('Define the parameters linked to your action areas πŸ‘‡')

needed_cols = ['name','system group', 'system type', 'geothermal', 'water body', 'wood', 'waste heat', 'biogas', 'start year', 'end year']

if geodataframe is not None:
    for col in needed_cols:
        if col.lower() not in geodataframe.columns:
            geodataframe[col.lower()] = np.nan

    geodataframe_edited = st.data_editor(
        geodataframe.drop(columns='geometry')[needed_cols],
        column_config={
            "system group": st.column_config.SelectboxColumn(
                "Group of systems",
                help = "The group of systems of the zone",
                options = [
                    "District heating network",
                    "Decentralized heating"
                ],
                required = True
            )
        },
        hide_index=True,
    )

    geodataframe_new = gpd.GeoDataFrame(geodataframe_edited, geometry = geodataframe['geometry'])
    geojson = geodataframe_new.to_json()
    
    st.download_button(
        label = "Dowload the zones", 
        data = geojson,
        file_name = "action_areas.geojson",
        mime="application/geo+json")
    
    # buildings_gdf = gpd.GeoDataFrame(buildings, geometry = gpd.points_from_xy(buildings["coordinate x"], buildings["coordinate y"]), crs = "EPSG:4326")
    


else:
    st.error('Action areas not uploaded. Please upload the action areas.', icon = "πŸ’‘")


st.markdown('**Heating system substitution**')
st.image('assets/Heating_system_substitution.png')

st.markdown('**District heating zones deployment**')
st.image('assets/District_heating_zones_deployment.png')

st.markdown('**Heat supply evolution**')
st.image('assets/Heat_supply_evolution.png')

st.markdown('**Final energy demand evolution**')
st.image('assets/Final_energy_demand_evolution.png')

st.markdown('**Greenhouse gas emissions evolution**')
st.image('assets/GHG_emissions_evolution.png')