ppsingh commited on
Commit
6f76a2b
β€’
1 Parent(s): a17b4cf

target stats

Browse files
Files changed (1) hide show
  1. 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='Sheet1')
 
 
 
 
 
40
  workbook = writer.book
41
- worksheet = writer.sheets['Sheet1']
42
- worksheet.data_validation('L2:L{}'.format(len_df),
43
- {'validate': 'list',
44
- 'source': ['No', 'Yes', 'Discard']})
45
- worksheet.data_validation('M2:L{}'.format(len_df),
46
- {'validate': 'list',
47
- 'source': ['No', 'Yes', 'Discard']})
48
- worksheet.data_validation('N2:L{}'.format(len_df),
49
- {'validate': 'list',
50
- 'source': ['No', 'Yes', 'Discard']})
51
- worksheet.data_validation('O2:L{}'.format(len_df),
52
- {'validate': 'list',
53
- 'source': ['No', 'Yes', 'Discard']})
54
- worksheet.data_validation('P2:L{}'.format(len_df),
55
- {'validate': 'list',
56
- 'source': ['No', 'Yes', 'Discard']})
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
- netzerohit = netzerohit.sort_values(by = ['Netzero Score'], ascending = False)
108
- # st.write('-------------------')
109
- # st.markdown("###### Netzero paragraph ######")
110
- st.write('**Netzero paragraph** `page {}`: {}'.format(netzerohit.iloc[0]['page'],
111
- netzerohit.iloc[0]['text'].replace("\n", " ")))
112
- st.write("")
113
- else:
114
- st.info("πŸ€” No Netzero paragraph found")
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
- # df_xlsx = to_excel(df)
134
 
135
- # with st.sidebar:
136
- # st.write('-------------')
137
- # st.download_button(label='πŸ“₯ Download Result',
138
- # data=df_xlsx ,
139
- # file_name= os.path.splitext(st.session_state['filename'])[0]+'.xlsx')
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")