restructure download
Browse files- appStore/target.py +37 -7
- utils/adapmit_classifier.py +1 -1
appStore/target.py
CHANGED
@@ -34,7 +34,7 @@ _lab_dict = {
|
|
34 |
}
|
35 |
|
36 |
@st.cache_data
|
37 |
-
def to_excel(df
|
38 |
# df['Target Validation'] = 'No'
|
39 |
# df['Netzero Validation'] = 'No'
|
40 |
# df['GHG Validation'] = 'No'
|
@@ -44,12 +44,41 @@ def to_excel(df,hits):
|
|
44 |
output = BytesIO()
|
45 |
writer = pd.ExcelWriter(output, engine='xlsxwriter')
|
46 |
df.to_excel(writer, index=False, sheet_name='rawdata')
|
47 |
-
if '
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
# hits = hits.drop(columns = ['Target Score','Netzero Score','GHG Score'])
|
52 |
-
hits.to_excel(writer,index=False,sheet_name = 'Target')
|
53 |
workbook = writer.book
|
54 |
# worksheet = writer.sheets['Sheet1']
|
55 |
# worksheet.data_validation('L2:L{}'.format(len_df),
|
@@ -152,10 +181,11 @@ def target_display():
|
|
152 |
# filtered_df = filtered_df[filtered_df.keep == True]
|
153 |
# st.write('Explore the data')
|
154 |
# AgGrid(hits)
|
155 |
-
|
156 |
|
157 |
with st.sidebar:
|
158 |
st.write('-------------')
|
|
|
159 |
st.download_button(label='📥 Download Result',
|
160 |
data=df_xlsx ,
|
161 |
file_name= os.path.splitext(os.path.basename(st.session_state['filename']))[0]+'.xlsx')
|
|
|
34 |
}
|
35 |
|
36 |
@st.cache_data
|
37 |
+
def to_excel(df):
|
38 |
# df['Target Validation'] = 'No'
|
39 |
# df['Netzero Validation'] = 'No'
|
40 |
# df['GHG Validation'] = 'No'
|
|
|
44 |
output = BytesIO()
|
45 |
writer = pd.ExcelWriter(output, engine='xlsxwriter')
|
46 |
df.to_excel(writer, index=False, sheet_name='rawdata')
|
47 |
+
if 'target_hits' in st.session_state:
|
48 |
+
target_hits = st.session_state['target_hits']
|
49 |
+
if 'keep' in target_hits.columns:
|
50 |
+
target_hits = target_hits[target_hits.keep == True]
|
51 |
+
target_hits = target_hits.reset_index(drop=True)
|
52 |
+
target_hits.drop(columns = ['keep'], inplace=True)
|
53 |
+
target_hits.to_excel(writer,index=False,sheet_name = 'Target')
|
54 |
+
else:
|
55 |
+
target_hits = df[df['Target Label'] == True]
|
56 |
+
target_hits.drop(columns=['Target Label','Netzero Score','GHG Score','Action Label',
|
57 |
+
'Action Score','Policies_Plans Label','Indicator Label',
|
58 |
+
'Policies_Plans Score','Conditional Score'],inplace=True)
|
59 |
+
target_hits = target_hits.sort_values(by=['Target Score'], ascending=False)
|
60 |
+
target_hits = target_hits.reset_index(drop=True)
|
61 |
+
target_hits.to_excel(writer,index=False,sheet_name = 'Target')
|
62 |
+
|
63 |
+
|
64 |
+
if 'action_hits' in st.session_state:
|
65 |
+
action_hits = st.session_state['action_hits']
|
66 |
+
if 'keep' in action_hits.columns:
|
67 |
+
action_hits = action_hits[action_hits.keep == True]
|
68 |
+
action_hits = action_hits.reset_index(drop=True)
|
69 |
+
action_hits.drop(columns = ['keep'], inplace=True)
|
70 |
+
action_hits.to_excel(writer,index=False,sheet_name = 'Action')
|
71 |
+
else:
|
72 |
+
action_hits = df[df['Action Label'] == True]
|
73 |
+
action_hits.drop(columns=['Target Label','Target Score','Netzero Score',
|
74 |
+
'Netzero Label','GHG Label',
|
75 |
+
'GHG Score','Action Label','Policies_Plans Label',
|
76 |
+
'Policies_Plans Score','Conditional Score'],inplace=True)
|
77 |
+
action_hits = action_hits.sort_values(by=['Action Score'], ascending=False)
|
78 |
+
action_hits = action_hits.reset_index(drop=True)
|
79 |
+
action_hits.to_excel(writer,index=False,sheet_name = 'Action')
|
80 |
+
|
81 |
# hits = hits.drop(columns = ['Target Score','Netzero Score','GHG Score'])
|
|
|
82 |
workbook = writer.book
|
83 |
# worksheet = writer.sheets['Sheet1']
|
84 |
# worksheet.data_validation('L2:L{}'.format(len_df),
|
|
|
181 |
# filtered_df = filtered_df[filtered_df.keep == True]
|
182 |
# st.write('Explore the data')
|
183 |
# AgGrid(hits)
|
184 |
+
|
185 |
|
186 |
with st.sidebar:
|
187 |
st.write('-------------')
|
188 |
+
df_xlsx = to_excel(df)
|
189 |
st.download_button(label='📥 Download Result',
|
190 |
data=df_xlsx ,
|
191 |
file_name= os.path.splitext(os.path.basename(st.session_state['filename']))[0]+'.xlsx')
|
utils/adapmit_classifier.py
CHANGED
@@ -107,4 +107,4 @@ def adapmit_classification(haystack_doc:pd.DataFrame,
|
|
107 |
df = df.reset_index(drop =True)
|
108 |
df.index += 1
|
109 |
|
110 |
-
return
|
|
|
107 |
df = df.reset_index(drop =True)
|
108 |
df.index += 1
|
109 |
|
110 |
+
return df
|