target stats
Browse files- appStore/target.py +43 -38
appStore/target.py
CHANGED
@@ -28,32 +28,37 @@ _lab_dict = {
|
|
28 |
|
29 |
@st.cache_data
|
30 |
def to_excel(df):
|
31 |
-
df['Target Validation'] = 'No'
|
32 |
-
df['Netzero Validation'] = 'No'
|
33 |
-
df['GHG Validation'] = 'No'
|
34 |
-
df['Adapt-Mitig Validation'] = 'No'
|
35 |
-
df['Sector'] = 'No'
|
36 |
len_df = len(df)
|
37 |
output = BytesIO()
|
38 |
writer = pd.ExcelWriter(output, engine='xlsxwriter')
|
39 |
-
df.to_excel(writer, index=False, sheet_name='
|
|
|
|
|
|
|
|
|
|
|
40 |
workbook = writer.book
|
41 |
-
worksheet = writer.sheets['Sheet1']
|
42 |
-
worksheet.data_validation('L2:L{}'.format(len_df),
|
43 |
-
|
44 |
-
|
45 |
-
worksheet.data_validation('M2:L{}'.format(len_df),
|
46 |
-
|
47 |
-
|
48 |
-
worksheet.data_validation('N2:L{}'.format(len_df),
|
49 |
-
|
50 |
-
|
51 |
-
worksheet.data_validation('O2:L{}'.format(len_df),
|
52 |
-
|
53 |
-
|
54 |
-
worksheet.data_validation('P2:L{}'.format(len_df),
|
55 |
-
|
56 |
-
|
57 |
writer.save()
|
58 |
processed_data = output.getvalue()
|
59 |
return processed_data
|
@@ -102,16 +107,16 @@ def target_display():
|
|
102 |
st.write('**Economy-wide Related Paragraphs**: `{}`'.format(count_economy))
|
103 |
st.write('-------------------')
|
104 |
hits = hits.sort_values(by=['Target Score'], ascending=False)
|
105 |
-
netzerohit = hits[hits['Netzero Label'] == 'NETZERO']
|
106 |
-
if not netzerohit.empty:
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
else:
|
114 |
-
|
115 |
|
116 |
# # st.write("**Result {}** `page {}` (Relevancy Score: {:.2f})'".format(i+1,hits.iloc[i]['page'],hits.iloc[i]['Relevancy'])")
|
117 |
# st.write('-------------------')
|
@@ -130,13 +135,13 @@ def target_display():
|
|
130 |
# st.write('----------------')
|
131 |
# st.write('Explore the data')
|
132 |
# st.write(hits)
|
133 |
-
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
|
141 |
# else:
|
142 |
# st.info("π€ No Targets found")
|
|
|
28 |
|
29 |
@st.cache_data
|
30 |
def to_excel(df):
|
31 |
+
# df['Target Validation'] = 'No'
|
32 |
+
# df['Netzero Validation'] = 'No'
|
33 |
+
# df['GHG Validation'] = 'No'
|
34 |
+
# df['Adapt-Mitig Validation'] = 'No'
|
35 |
+
# df['Sector'] = 'No'
|
36 |
len_df = len(df)
|
37 |
output = BytesIO()
|
38 |
writer = pd.ExcelWriter(output, engine='xlsxwriter')
|
39 |
+
df.to_excel(writer, index=False, sheet_name='rawdata')
|
40 |
+
hits = df[df['Target Label'] == 'TARGET']
|
41 |
+
hits = hits.reset_index(drop=True)
|
42 |
+
hits = hits.sort_values(by=['Target Score'], ascending=False)
|
43 |
+
hits = hits.drop(columns = ['Target Score','Netzero Score','GHG Score'])
|
44 |
+
hits.to_excel(writer,index=False,sheet_name = 'Target')
|
45 |
workbook = writer.book
|
46 |
+
# worksheet = writer.sheets['Sheet1']
|
47 |
+
# worksheet.data_validation('L2:L{}'.format(len_df),
|
48 |
+
# {'validate': 'list',
|
49 |
+
# 'source': ['No', 'Yes', 'Discard']})
|
50 |
+
# worksheet.data_validation('M2:L{}'.format(len_df),
|
51 |
+
# {'validate': 'list',
|
52 |
+
# 'source': ['No', 'Yes', 'Discard']})
|
53 |
+
# worksheet.data_validation('N2:L{}'.format(len_df),
|
54 |
+
# {'validate': 'list',
|
55 |
+
# 'source': ['No', 'Yes', 'Discard']})
|
56 |
+
# worksheet.data_validation('O2:L{}'.format(len_df),
|
57 |
+
# {'validate': 'list',
|
58 |
+
# 'source': ['No', 'Yes', 'Discard']})
|
59 |
+
# worksheet.data_validation('P2:L{}'.format(len_df),
|
60 |
+
# {'validate': 'list',
|
61 |
+
# 'source': ['No', 'Yes', 'Discard']})
|
62 |
writer.save()
|
63 |
processed_data = output.getvalue()
|
64 |
return processed_data
|
|
|
107 |
st.write('**Economy-wide Related Paragraphs**: `{}`'.format(count_economy))
|
108 |
st.write('-------------------')
|
109 |
hits = hits.sort_values(by=['Target Score'], ascending=False)
|
110 |
+
# netzerohit = hits[hits['Netzero Label'] == 'NETZERO']
|
111 |
+
# if not netzerohit.empty:
|
112 |
+
# netzerohit = netzerohit.sort_values(by = ['Netzero Score'], ascending = False)
|
113 |
+
# # st.write('-------------------')
|
114 |
+
# # st.markdown("###### Netzero paragraph ######")
|
115 |
+
# st.write('**Netzero paragraph** `page {}`: {}'.format(netzerohit.iloc[0]['page'],
|
116 |
+
# netzerohit.iloc[0]['text'].replace("\n", " ")))
|
117 |
+
# st.write("")
|
118 |
+
# else:
|
119 |
+
# st.info("π€ No Netzero paragraph found")
|
120 |
|
121 |
# # st.write("**Result {}** `page {}` (Relevancy Score: {:.2f})'".format(i+1,hits.iloc[i]['page'],hits.iloc[i]['Relevancy'])")
|
122 |
# st.write('-------------------')
|
|
|
135 |
# st.write('----------------')
|
136 |
# st.write('Explore the data')
|
137 |
# st.write(hits)
|
138 |
+
df_xlsx = to_excel(df)
|
139 |
|
140 |
+
with st.sidebar:
|
141 |
+
st.write('-------------')
|
142 |
+
st.download_button(label='π₯ Download Result',
|
143 |
+
data=df_xlsx ,
|
144 |
+
file_name= os.path.splitext(st.session_state['filename'])[0]+'.xlsx')
|
145 |
|
146 |
# else:
|
147 |
# st.info("π€ No Targets found")
|