Skip to main content

Measure school belonging and identify social stressor patterns in adolescent survey data.

Project description

belonginglab

belonginglab is a Python library for measuring school belonging and identifying social stressor patterns in adolescent survey data. It is designed around the CDC YRBSS 2023 release, which includes recent topics such as social media use, racism in schools, unfair discipline, and school connectedness.

Why belonging?

Adolescent well-being is shaped not only by internal emotional states but by the school environment around a student. belonginglab treats belonging as a measurable, systems-level construct — a composite of connectedness, supportive adult relationships, and the absence of bullying, discrimination, and discipline inequity.

Supported datasets

  • CDC YRBSS 2023 (national and state files, CSV or SAS export)
  • Custom surveys, via a user-supplied variable-name mapping

Install

pip install belonginglab
# with plotting:
pip install "belonginglab[plots]"

Quickstart

from belonginglab import (
    load_yrbss, map_variables, clean_yrbss,
    compute_belonging_score, flag_stressors,
    count_stressor_stack, compare_groups,
    generate_summary_report,
)

df = load_yrbss("yrbs_2023.csv")
df = map_variables(df, schema="yrbss_2023")
df = clean_yrbss(df)

df = compute_belonging_score(df)
df = flag_stressors(df)

stack = count_stressor_stack(df)
print(stack.summary())

print(compare_groups(df, by="race_ethnicity"))
print(generate_summary_report(df, group_by="sex"))

Try it without downloading anything:

from belonginglab import make_synthetic_yrbss, compute_belonging_score, flag_stressors
df = compute_belonging_score(make_synthetic_yrbss(n=500))
df = flag_stressors(df)

Core API

Function Purpose
load_yrbss(path) Read CSV, .sas7bdat, or .xpt
map_variables(df, schema) Rename raw Q-codes to canonical names
clean_yrbss(df, subgroup=...) Coerce missing values and optionally filter
compute_belonging_score(df) Add a 0–100 belonging-score column
flag_stressors(df) Add binary stressor flags
count_stressor_stack(df) Distribution of stressor counts per respondent
compare_groups(df, by=...) Subgroup table (n, score stats, stressor prevalence)
generate_summary_report(df) Markdown/text summary, optionally written to file

Methodology note

The default belonging score is a weighted z-score composite:

  • Positive contributors: school connectedness, supportive-adult indicator
  • Negative contributors: bullying (school + electronic), racism in school, unfair discipline, heavy social media use, sadness/hopelessness

Each component is z-scored, multiplied by its weight (see belonginglab.DEFAULT_WEIGHTS), summed, and — by default — percentile-ranked to a 0–100 scale for interpretability. Weights and scaling are user-overridable. Variables absent from the dataset are skipped rather than imputed.

Ethical note

belonginglab is for research and educational analysis. It does not diagnose mental health conditions or determine individual student risk. Scores should be interpreted at the population or subgroup level, not at the level of a single student.

Roadmap

  • v0.1 (MVP): loader, belonging score, four stressor flags, group comparison, summary report
  • v0.2: weighted survey estimates (weight, strata, psu), trend comparison across years
  • v0.3: additional schemas (state YRBSS releases, Healthy Minds, other adolescent surveys)
  • v0.4: clustering/latent-class stressor patterns

License

MIT © Akshara Balakrishnan

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

belonginglab-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

belonginglab-0.1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file belonginglab-0.1.0.tar.gz.

File metadata

  • Download URL: belonginglab-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for belonginglab-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9a1be4ebb2d88a43d67958349505519a47554f08fcff51be0458a6237f881e16
MD5 dc9b461325fae82292084abd90b57c14
BLAKE2b-256 a24e4ea27c555aeda0ec05e68854e949ec4483023a5d1c8a66e0844c7d8eb903

See more details on using hashes here.

File details

Details for the file belonginglab-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: belonginglab-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for belonginglab-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0ef8e94e8db07c5ed8cf0cf9f3fccaad0d5ff2a02a4fb1b1522ac1572f37bdc
MD5 f948f542781f714c285c13cb5ff345b8
BLAKE2b-256 a64bbeff99c52662f12503375f397aa0846eb0bba8f3cee01537634ee783b6d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page