Action and Policy filtering
Browse files- appStore/policyaction.py +26 -3
appStore/policyaction.py
CHANGED
@@ -27,7 +27,7 @@ from pandas.api.types import (
|
|
27 |
classifier_identifier = 'policyaction'
|
28 |
params = get_classifier_params(classifier_identifier)
|
29 |
|
30 |
-
@st.cache_data
|
31 |
def to_excel(df):
|
32 |
# df['Target Validation'] = 'No'
|
33 |
# df['Netzero Validation'] = 'No'
|
@@ -174,6 +174,13 @@ def app():
|
|
174 |
|
175 |
st.session_state.key1 = df
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
|
179 |
def action_display():
|
@@ -197,6 +204,10 @@ def action_display():
|
|
197 |
|
198 |
|
199 |
st.caption("Filter table to select rows to keep for Action category")
|
|
|
|
|
|
|
|
|
200 |
filter_dataframe_action(hits)
|
201 |
# filtered_df = filtered_df[filtered_df.keep == True]
|
202 |
# st.write('Explore the data')
|
@@ -243,7 +254,11 @@ def filter_dataframe_action(df: pd.DataFrame) -> pd.DataFrame:
|
|
243 |
modification_container = st.container()
|
244 |
|
245 |
with modification_container:
|
246 |
-
|
|
|
|
|
|
|
|
|
247 |
for column in to_filter_columns:
|
248 |
left, right = st.columns((1, 20))
|
249 |
left.write("↳")
|
@@ -347,7 +362,11 @@ def filter_dataframe_policy(df: pd.DataFrame) -> pd.DataFrame:
|
|
347 |
modification_container = st.container()
|
348 |
|
349 |
with modification_container:
|
350 |
-
|
|
|
|
|
|
|
|
|
351 |
for column in to_filter_columns:
|
352 |
left, right = st.columns((1, 20))
|
353 |
left.write("↳")
|
@@ -440,6 +459,10 @@ def policy_display():
|
|
440 |
|
441 |
|
442 |
st.caption("Filter table to select rows to keep for Policies and Plans category")
|
|
|
|
|
|
|
|
|
443 |
filter_dataframe_policy(hits)
|
444 |
# filtered_df = filtered_df[filtered_df.keep == True]
|
445 |
# st.write('Explore the data')
|
|
|
27 |
classifier_identifier = 'policyaction'
|
28 |
params = get_classifier_params(classifier_identifier)
|
29 |
|
30 |
+
# @st.cache_data
|
31 |
def to_excel(df):
|
32 |
# df['Target Validation'] = 'No'
|
33 |
# df['Netzero Validation'] = 'No'
|
|
|
174 |
|
175 |
st.session_state.key1 = df
|
176 |
|
177 |
+
def filter_for_tracs(df):
|
178 |
+
sector_list = ['Transport','Energy','Economy-wide']
|
179 |
+
df['check'] = df['Sector Label'].apply(lambda x: any(i in x for i in sector_list))
|
180 |
+
df = df[df.check == True].reset_index(drop=True)
|
181 |
+
df['Sector Label'] = df['Sector Label'].apply(lambda x: [i for i in x if i in sector_list])
|
182 |
+
df.drop(columns = ['check'],inplace=True)
|
183 |
+
return df
|
184 |
|
185 |
|
186 |
def action_display():
|
|
|
204 |
|
205 |
|
206 |
st.caption("Filter table to select rows to keep for Action category")
|
207 |
+
hits = filter_for_tracs(hits)
|
208 |
+
convert_type = {'Conditional Label':'category',
|
209 |
+
}
|
210 |
+
hits = hits.astype(convert_type)
|
211 |
filter_dataframe_action(hits)
|
212 |
# filtered_df = filtered_df[filtered_df.keep == True]
|
213 |
# st.write('Explore the data')
|
|
|
254 |
modification_container = st.container()
|
255 |
|
256 |
with modification_container:
|
257 |
+
cols = list(set(df.columns) -{'page','Extracted Text'})
|
258 |
+
cols.sort()
|
259 |
+
to_filter_columns = st.multiselect("Filter dataframe on", cols
|
260 |
+
)
|
261 |
+
# to_filter_columns = st.multiselect("Filter dataframe on", df.columns)
|
262 |
for column in to_filter_columns:
|
263 |
left, right = st.columns((1, 20))
|
264 |
left.write("↳")
|
|
|
362 |
modification_container = st.container()
|
363 |
|
364 |
with modification_container:
|
365 |
+
cols = list(set(df.columns) -{'page','Extracted Text'})
|
366 |
+
cols.sort()
|
367 |
+
to_filter_columns = st.multiselect("Filter dataframe on", cols
|
368 |
+
)
|
369 |
+
# to_filter_columns = st.multiselect("Filter dataframe on", df.columns)
|
370 |
for column in to_filter_columns:
|
371 |
left, right = st.columns((1, 20))
|
372 |
left.write("↳")
|
|
|
459 |
|
460 |
|
461 |
st.caption("Filter table to select rows to keep for Policies and Plans category")
|
462 |
+
hits = filter_for_tracs(hits)
|
463 |
+
convert_type = {'Conditional Label':'category',
|
464 |
+
}
|
465 |
+
hits = hits.astype(convert_type)
|
466 |
filter_dataframe_policy(hits)
|
467 |
# filtered_df = filtered_df[filtered_df.keep == True]
|
468 |
# st.write('Explore the data')
|