Update app.py
Browse filesfilter columns for download; allow selecting multiple agencies from settings menu
app.py
CHANGED
@@ -34,7 +34,7 @@ with ui.sidebar(title="Settings"):
|
|
34 |
|
35 |
ui.input_switch("switch", "Show significant rules in plots", False)
|
36 |
|
37 |
-
ui.input_select("menu_agency", "Select agencies", choices=["all"] + AGENCIES, selected="all")
|
38 |
|
39 |
#ui.input_checkbox_group(
|
40 |
# "significant",
|
@@ -150,9 +150,30 @@ with ui.accordion(open=False):
|
|
150 |
label="Download data as CSV",
|
151 |
filename=f"rules_in_cra_window_accessed_{date.today()}.csv",
|
152 |
)
|
153 |
-
async def download(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
await asyncio.sleep(0.25)
|
155 |
-
yield filtered_df().to_csv(index=False)
|
156 |
|
157 |
with ui.accordion(open=False):
|
158 |
|
@@ -187,8 +208,8 @@ def filtered_df():
|
|
187 |
filt_df = filt_df.loc[filt_df["publication_date"] >= datetime.combine(input.start_date(), time(0, 0))]
|
188 |
|
189 |
# filter agencies
|
190 |
-
if input.menu_agency()
|
191 |
-
bool_agency = [True if input.menu_agency()
|
192 |
filt_df = filt_df.loc[bool_agency]
|
193 |
|
194 |
return filt_df
|
|
|
34 |
|
35 |
ui.input_switch("switch", "Show significant rules in plots", False)
|
36 |
|
37 |
+
ui.input_select("menu_agency", "Select agencies", choices=["all"] + AGENCIES, selected="all", multiple=True)
|
38 |
|
39 |
#ui.input_checkbox_group(
|
40 |
# "significant",
|
|
|
150 |
label="Download data as CSV",
|
151 |
filename=f"rules_in_cra_window_accessed_{date.today()}.csv",
|
152 |
)
|
153 |
+
async def download(
|
154 |
+
output_cols: tuple | list = (
|
155 |
+
"document_number",
|
156 |
+
"citation",
|
157 |
+
"publication_date",
|
158 |
+
"title",
|
159 |
+
"type",
|
160 |
+
"action",
|
161 |
+
"abstract",
|
162 |
+
"docket_ids",
|
163 |
+
"json_url",
|
164 |
+
"html_url",
|
165 |
+
"agencies",
|
166 |
+
"independent_reg_agency",
|
167 |
+
"parent_slug",
|
168 |
+
"subagency_slug",
|
169 |
+
"president_id",
|
170 |
+
"significant",
|
171 |
+
"3f1_significant",
|
172 |
+
"other_significant"
|
173 |
+
)
|
174 |
+
):
|
175 |
await asyncio.sleep(0.25)
|
176 |
+
yield filtered_df().loc[:, output_cols].to_csv(index=False)
|
177 |
|
178 |
with ui.accordion(open=False):
|
179 |
|
|
|
208 |
filt_df = filt_df.loc[filt_df["publication_date"] >= datetime.combine(input.start_date(), time(0, 0))]
|
209 |
|
210 |
# filter agencies
|
211 |
+
if (input.menu_agency() is not None) and ("all" not in input.menu_agency()):
|
212 |
+
bool_agency = [True if sum(selected in agency for selected in input.menu_agency()) > 0 else False for agency in filt_df["parent_slug"]]
|
213 |
filt_df = filt_df.loc[bool_agency]
|
214 |
|
215 |
return filt_df
|