Skip to content

Commit

Permalink
some new metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
linozen committed Aug 31, 2021
1 parent f472479 commit bb37fa2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 5 deletions.
22 changes: 18 additions & 4 deletions explorer/civsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,9 +1224,9 @@ def callback():
###############################################################################


df.to_pickle("./data/civsoc.pkl")
df.to_excel("./data/civsoc.xlsx")
df.to_csv("./data/civsoc.csv")
# df.to_pickle("./data/civsoc.pkl")
# df.to_excel("./data/civsoc.xlsx")
# df.to_csv("./data/civsoc.csv")


###############################################################################
Expand Down Expand Up @@ -1265,7 +1265,21 @@ def callback():
col1.metric("Civil Society Representatives", len(df[filter].index))
col2.metric(
"Cumulative years spent working on SBIA",
int(df[filter]["CSexpertise1"].sum()),
df[filter]["CSexpertise1"].sum(),
)

col1, col2 = st.columns(2)
col1.metric(
"Average years spent working on SBIA†",
"%.1f" % df[filter]["CSexpertise1"].mean(),
)
col2.metric(
"Average Number of FOI requests sent in the past 5 years",
int(df[filter]["CSfoi2"].mean()),
)

st.caption(
"†For the calculation of the mean, only valid numerical answers were counted. This is why the number might differ from the number one gets when simply dividing e.g. the cumulative years spent working on SBIA by the overall number of respondents (including those who haven't specified their experience in years)."
)

st.write("### Country `[country]`")
Expand Down
26 changes: 25 additions & 1 deletion explorer/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,31 @@ def callback():
col1.metric("Media representatives", len(df[filter].index))
col2.metric(
"Cumulative years spent working on SBIA",
int(df[filter]["MSexpertise1"].sum()),
df[filter]["MSexpertise1"].sum(),
)

col1, col2 = st.columns(2)
col1.metric(
"Average years spent working on SBIA†",
"%.1f" % df[filter]["MSexpertise1"].mean(),
)
col2.metric(
"Average Number of FOI requests sent in the past 5 years",
int(df[filter]["MSfoi2"].mean()),
)

col1, col2 = st.columns(2)
col1.metric(
"Articles written on SBIA in the last year",
"%.1f" % df[filter]["MSsoc2"].sum(),
)
col2.metric(
"Average Articles written on SBIA in the last year",
"%.1f" % df[filter]["MSsoc2"].mean(),
)

st.caption(
"†For the calculation of the mean, only valid numerical answers were counted. This is why the number might differ from the number one gets when simply dividing e.g. the cumulative years spent working on SBIA by the overall number of respondents (including those who haven't specified their experience in years)."
)

st.write("### Country `[country]`")
Expand Down
14 changes: 14 additions & 0 deletions explorer/merged.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,16 @@ def callback():
int(df[filter]["expertise1"].sum()),
)

col1, col2 = st.columns(2)
col1.metric(
"Average years spent working on SBIA†",
"%.1f" % df[filter]["expertise1"].mean(),
)
col2.metric(
"Average Number of FOI requests sent in the past 5 years",
int(df[filter]["foi2"].mean()),
)

col1, col2 = st.columns(2)
col1.metric(
"Media representatives",
Expand All @@ -1010,6 +1020,10 @@ def callback():
len(df[filter & (df.surveytype == "Civil Society Scrutiny")].index),
)

st.caption(
"†For the calculation of the mean, only valid numerical answers were counted. This is why the number might differ from the number one gets when simply dividing e.g. the cumulative years spent working on SBIA by the overall number of respondents (including those who haven't specified their experience in years)."
)

st.write("### Country `[country]`")
country_counts = df[filter]["country"].value_counts()
st.plotly_chart(
Expand Down

0 comments on commit bb37fa2

Please sign in to comment.