kailo_beewell_dashboard.explore_results

Helper functions for the explore_results() section of dashboard and PDF report.

Module Contents

Functions

write_page_title([output, survey_type])

Writes the title of this page/section (Explore Results), for the streamlit

create_topic_dict(df)

Generate dictionary of survey topics with keys as the topic labels

choose_topic(df[, include_raw_name])

Create topic dictionary and produce selectbox for users to choose a topic

write_topic_intro(chosen_variable, chosen_variable_lab, df)

Writes the header for the topic on the Explore Results streamlit page or

write_response_section_intro(chosen_variable_lab[, ...])

Create the header and description for the section with the bar charts

get_chosen_result(chosen_variable, chosen_group, df, ...)

Filters the dataframe with responses to each question, to just responses

reverse_categories(df)

Resorts dataframe so categories are in reverse order, but ensuring

define_multiple_charts()

Create a dictionary designating which topics have charts that needed to be

create_bar_charts(chosen_variable, chosen_result[, ...])

Creates the section of bar charts and their accompanying text, for

write_comparison_intro(chosen_variable, ...[, output, ...])

Write the introduction to the comparison section (heading, description

write_comparison_result(chosen_school, ...[, output, ...])

Write the introduction to the comparison section (heading, description

create_explore_topic_page(chosen_variable_lab, ...)

Add an explore results page with responses to a given topic to report HTML.

kailo_beewell_dashboard.explore_results.write_page_title(output='streamlit', survey_type='standard')

Writes the title of this page/section (Explore Results), for the streamlit page or for the PDF report.

Parameters

outputstring

Specifies whether to write for ‘streamlit’ (default) or ‘pdf’.

survey_typestring

Specifies whether this is for the ‘standard’ or ‘symbol’ survey.

Returns

html_stringstring

Optional return, used when output==’pdf’, contains HTML for report.

kailo_beewell_dashboard.explore_results.create_topic_dict(df)

Generate dictionary of survey topics with keys as the topic labels (‘variable_lab’) and values as the raw topic strings (‘variable’).

Parameters

dfpandas dataframe

Dataframe containing the ‘variable’ and ‘variable_lab’ columns

Returns

topic_dictdictionary

Dictionary to map between topic raw names and label names

kailo_beewell_dashboard.explore_results.choose_topic(df, include_raw_name=False)

Create topic dictionary and produce selectbox for users to choose a topic

Parameters

dfDataframe

Dataframe which includes columns with topic names

include_raw_nameBoolean

Whether to include the raw version of the topic name

Returns

chosen_variable_labString

Full and capitalised topic name

chosen_variableString

Raw version of topic name

kailo_beewell_dashboard.explore_results.write_topic_intro(chosen_variable, chosen_variable_lab, df, output='streamlit', content=None)

Writes the header for the topic on the Explore Results streamlit page or in HTML for page of PDF report. Example output:

Psychological Wellbeing These questions are about how positive and generally happy young people feel regarding their life.

Parameters

chosen_variablestring

Chosen variable in simple format (e.g. ‘psychological_wellbeing’)

chosen_variable_labstring

Chosen variable in label format (e.g. ‘Psychological wellbeing’)

dfpandas dataframe

Dataframe containing the ‘variable’ and ‘description’ columns for each topic.

outputstring

Specifies whether to write for ‘streamlit’ (default) or ‘pdf’.

contentlist

Optional input used when output==’pdf’, contains HTML for report.

Returns

contentlist

Optional return, used when output==’pdf’, contains HTML for report.

kailo_beewell_dashboard.explore_results.write_response_section_intro(chosen_variable_lab, output='streamlit', content=None, type='school')

Create the header and description for the section with the bar charts showing responses from pupils to each question of a topic. Example output:

Responses from pupils at your school In this section, you can see how pupils at you school responded to survey questions that relate to the topic of ‘psychological wellbeing’.

Parameters

chosen_variable_labstring

Chosen variable in label format (e.g. ‘Psychological wellbeing’)

outputstring

Specifies whether to write for ‘streamlit’ (default) or ‘pdf’.

contentlist

Optional input used when output==’pdf’, contains HTML for report.

typestring

Specifies whether it is a ‘school’ (default) or ‘public’ dashboard

Returns

contentlist

Optional return, used when output==’pdf’, contains HTML for report.

kailo_beewell_dashboard.explore_results.get_chosen_result(chosen_variable, chosen_group, df, school, survey_type='standard')

Filters the dataframe with responses to each question, to just responses for the chosen topic, school and group.

Parameters

chosen_variablestring

Name of the chosen topic

chosen_groupstring

Name of the chosen group to view results by - options are ‘For all pupils’, ‘By year group’, ‘By gender’, ‘By FSM’ or ‘By SEN’

dfdataframe

Dataframe with responses to all the questions for all topics

schoolstring

Name of school to get results for

survey_typestring

Specifies whether it is ‘standard’ (default) or ‘symbol’ survey

Returns

chosen_resultdataframe

Contains responses to each question in the chosen topic, with the results extracted so they are in seperate rows and columns (rather than original format where they are nested in lists)

kailo_beewell_dashboard.explore_results.reverse_categories(df)

Resorts dataframe so categories are in reverse order, but ensuring non-response is still at the end (despite it being the max value).

Parameters:

dfdataframe

Dataframe with question responses, to be resorted

Returns:

new_dfdataframe

Resorted dataframe

kailo_beewell_dashboard.explore_results.define_multiple_charts()

Create a dictionary designating which topics have charts that needed to be seperated, and how this should be done. This is to create seperate clusters of charts (so there can be text describing one group of charts, then text describing another - e.g. when they’re the same topic but have different sets of responses options).

Returns

multiple_chartsdictionary

Dictionary where key is variable and value is dictionary with sub-groups of topic questions

kailo_beewell_dashboard.explore_results.create_bar_charts(chosen_variable, chosen_result, output='streamlit', content=None)

Creates the section of bar charts and their accompanying text, for streamlit page or PDF report.

Parameters

chosen_variablestring

Name of the chosen topic

chosen_resultdataframe

Contains responses to each question in the chosen topic, school + group

outputstring

Specifies whether to write for ‘streamlit’ (default) or ‘pdf’.

contentlist

Optional input used when output==’pdf’, contains HTML for report.

Returns

contentlist

Optional return, used when output==’pdf’, contains HTML for report.

kailo_beewell_dashboard.explore_results.write_comparison_intro(chosen_variable, chosen_variable_lab, score_descriptions, output='streamlit', content=None)

Write the introduction to the comparison section (heading, description and RAG rating)

Parameters

chosen_variablestring

Chosen variable (e.g. ‘autonomy’)

chosen_variable_labstring

Label for the chosen variable (e.g. ‘Autonomy’)

score_descriptionsdictionary

Dictionary with variable and then the appropriate descriptions for this section (range of score, and interpretation of score)

outputstring

Specifies whether to write for ‘streamlit’ (default) or ‘pdf’.

contentlist

Optional input used when output==’pdf’, contains HTML for report.

Returns

contentlist

Optional return, used when output==’pdf’, contains HTML for report.

kailo_beewell_dashboard.explore_results.write_comparison_result(chosen_school, between_schools, group, output='streamlit', content=None)

Write the introduction to the comparison section (heading, description and RAG rating)

Parameters

chosen_schoolstring

Name of chosen school

between_schools: dataframe

Dataframe with scores for the chosen variable in each school

outputstring

Specifies whether to write for ‘streamlit’ (default) or ‘pdf’.

contentlist

Optional input used when output==’pdf’, contains HTML for report.

groupstring

Pupil group

Returns

contentlist

Optional return, used when output==’pdf’, contains HTML for report.

kailo_beewell_dashboard.explore_results.create_explore_topic_page(chosen_variable_lab, topic_dict, df_scores, chosen_school, chosen_group, df_prop, content)

Add an explore results page with responses to a given topic to report HTML.

Parameters

chosen_variable_labstring

Chosen variable in label format (e.g. ‘Psychological wellbeing’)

topic_dictdictionary

Dictionary of topics where key is variable_lab and value is variable

df_scoresdataframe

Dataframe with scores for each topic

chosen_schoolstring

Name of the chosen school

chosen_groupstring

Name of the chosen group to view results by - options are ‘For all pupils’, ‘By year group’, ‘By gender’, ‘By FSM’ or ‘By SEN’

df_propdataframe

Dataframe with the proportion of pupils providing each response to each survey question

contentlist

Optional input used when output==’pdf’, contains HTML for report.

Returns

contentlist

Optional return, used when output==’pdf’, contains HTML for report.