Spaces:
Sleeping
Sleeping
File size: 4,593 Bytes
02e9842 f950742 02e9842 f950742 bf86382 f950742 7d49dd9 d2e7ba0 f950742 02e9842 80f8296 b305b8d 02e9842 80f8296 02e9842 05aeae7 98dd01b 05aeae7 42078dd bf86382 a3b9808 05aeae7 7836b2c a3b9808 7836b2c a3b9808 05aeae7 7836b2c 9aba080 05aeae7 7836b2c 05aeae7 98dd01b a3b9808 05aeae7 7836b2c 05aeae7 7836b2c 05aeae7 7836b2c 05aeae7 7836b2c 05aeae7 7836b2c 05aeae7 7836b2c 05aeae7 7836b2c 05aeae7 7836b2c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | import pandas as pd
import streamlit as st
import codebook as cb
import read_write as rw
import process as proc
import visualisations as vis
page_title = "Outputs"
st.title(page_title)
with st.spinner(rw.PROC_TEXT):
(dset, _) = rw.get_data(rw.DATA_PPROC_OUTPUTS)
dset_to_print = pd.DataFrame.from_dict(
{
"Outputs records": dset.shape[0],
"Institutions": dset[cb.COL_INST_NAME].nunique()
},
orient="index"
)
dset_to_print.columns = ["count"]
pd.set_option("display.max_colwidth", None)
st.dataframe(dset_to_print)
tab1, tab2, tab3 = st.tabs(["All records", "Explore types", "Search titles"])
with tab1:
st.markdown("Select from the charts below to view the "
"distributions for the number of outputs records by ...")
columns = [cb.COL_PANEL_NAME,
cb.COL_UOA_NAME,
cb.COL_OUTPUT_TYPE_NAME,
cb.COL_OUTPUT_INTERDISCIPLINARY,
cb.COL_OPEN_ACCESS]
tabs = st.tabs(columns)
for i, column in enumerate(columns):
with tabs[i]:
dset_stats = proc.calculate_counts(dset,
column,
sort=False)
vis.draw_counts_percent_chart(dset_stats,
column)
with tab2:
search_type = st.selectbox("Select an output type to display",
[""] + list(cb.OUTPUT_TYPE_NAMES.values()),
index=0
)
if search_type:
with st.spinner(rw.PROC_TEXT):
dset_selected = dset[dset[cb.COL_OUTPUT_TYPE_NAME] == search_type]
st.markdown(f"Number of outputs records of type '{search_type}': "
f"{dset_selected.shape[0]}")
rw.download_data(dset_selected,
f"Download '{search_type}' outputs as csv",
"selected_data.csv")
st.markdown("Select from the charts below to view the "
"distributions for the number of selected outputs records by ...")
columns = [cb.COL_PANEL_NAME,
cb.COL_UOA_NAME,
cb.COL_OUTPUT_INTERDISCIPLINARY,
cb.COL_OPEN_ACCESS]
tabs = st.tabs(columns)
for i, column in enumerate(columns):
with tabs[i]:
dset_stats = proc.calculate_counts(dset_selected,
column,
sort=False)
vis.draw_counts_percent_chart(dset_stats,
column)
with tab3:
search_word = st.text_input(f"Enter a term to search the '{cb.COL_OUTPUT_TITLE}'"
" of the outputs,"
" for example software,"
" computation, database, machine learning etc.",
max_chars=40,
value="",
help="Enter a term to search for."
)
search_column = cb.COL_OUTPUT_TITLE
if search_word:
with st.spinner(rw.PROC_TEXT):
dset_selected = dset[dset[search_column].str.contains(search_word,
case=False,
na=False)]
st.markdown(f"Number of outputs records with '{search_word}' in '{search_column}': "
f"{dset_selected.shape[0]}")
rw.download_data(dset_selected,
f"Download outputs with '{search_word}' in '{search_column}' as csv",
"selected_data.csv")
st.markdown("Select from the charts below to view the "
"distributions for the number of selected outputs records by ...")
columns = [cb.COL_PANEL_NAME,
cb.COL_UOA_NAME,
cb.COL_OUTPUT_TYPE_NAME,
cb.COL_OUTPUT_INTERDISCIPLINARY,
cb.COL_OPEN_ACCESS]
tabs = st.tabs(columns)
for i, column in enumerate(columns):
with tabs[i]:
dset_stats = proc.calculate_counts(dset_selected,
column,
sort=False)
vis.draw_counts_percent_chart(dset_stats,
column)
|