Trends, segmentation, and hierarchy analysis with vivaglint for Python

This article covers three analytical dimensions that extend beyond a single survey snapshot: tracking change over time with multi-cycle comparison, breaking down results by employee attributes, and rolling up scores to the manager level.

Note

All functions on this page require scale_points (valid range: 2-11).

Compare survey cycles

compare_cycles() accepts two or more survey objects and returns per-cycle metrics with change scores calculated relative to the prior cycle.

from vivaglint import compare_cycles

trends = compare_cycles(
    survey_q1, survey_q2, survey_q3,
    scale_points=5,
    cycle_names=["Q1 FY25", "Q2 FY25", "Q3 FY25"],
)
Parameter Type Default Description
*surveys GlintSurvey or DataFrame (required) Two or more survey objects in chronological order
scale_points int (required) Number of scale points (2-11)
cycle_names list[str] None Labels for each cycle; defaults to "Cycle 1", "Cycle 2", ...
plot bool False If True, display a line chart of Glint Score over cycles

The output adds three change columns:

  • change_from_previous — change in raw mean vs. prior cycle
  • pct_change_from_previous — percentage change in raw mean vs. prior cycle
  • glint_score_change_from_previous — change in Glint Score vs. prior cycle

Segment by employee attributes

analyze_by_attributes() calculates the same question-level metrics as summarize_survey() for each combination of attribute group values.

from vivaglint import analyze_by_attributes, join_attributes

# Option 1: join attributes first
survey_enriched = join_attributes(survey, "employee_data.csv")

results = analyze_by_attributes(
    survey_enriched,
    scale_points=5,
    attribute_cols=["Department", "Job Level"],
    min_group_size=10,
)

# Option 2: supply attribute file inline
results_inline = analyze_by_attributes(
    survey,
    attribute_file="employee_data.csv",
    scale_points=5,
    attribute_cols="Department",
)
Parameter Type Default Description
survey GlintSurvey or DataFrame (required) Survey data (attributes pre-joined or supplied via attribute_file)
attribute_file str None Path to attribute CSV; omitted if already joined
scale_points int (required) Number of scale points (2-11)
attribute_cols str or list[str] (required) Column(s) to group by
emp_id_col str None Employee ID column name (required for plain DataFrames)
min_group_size int 5 Minimum employees per group
plot bool False If True, display a faceted dot plot

Important

min_group_size is a privacy safeguard. Groups smaller than this size are excluded from results.

Roll up results by manager

aggregate_by_manager() calculates question-level metrics for each manager's team, using the Manager ID column to identify team membership.

from vivaglint import aggregate_by_manager

mgr_results = aggregate_by_manager(
    survey,
    scale_points=5,
    manager_id_col="Manager ID",
)
Parameter Type Default Description
survey GlintSurvey or DataFrame (required) Survey data
scale_points int (required) Number of scale points (2-11)
emp_id_col str None Employee ID column name (resolved from metadata if omitted)
manager_id_col str "Manager ID" Manager ID column name
full_tree bool False If True, include all indirect reports (full tree)
plot bool False If True, display a ranked lollipop chart

aggregate_by_manager() uses First Name and Last Name columns to construct manager names. If those columns are missing, manager names are left blank.

Direct reports vs. full tree

Set full_tree=True to include all indirect reports (full org subtree) for each manager:

mgr_results_full = aggregate_by_manager(
    survey,
    scale_points=5,
    full_tree=True,
)

Next steps