vivainsights.create_radar¶
create_radar: Parameterized radar-chart workflow (calc + viz + wrapper), in the same spirit as create_bar.
Core design¶
General-purpose: works with any HR attribute column.
- Calculation pipeline:
person-level aggregation within each group
group-level aggregation
minimum group size (mingroup)
indexing modes: “total”, “none”, “ref_group”, “minmax”
Returns either a plot or a table.
Typical usage¶
>>> import vivainsights as vi
>>> from vivainsights.create_radar import create_radar
>>>
>>> pq_data = vi.load_pq_data()
>>> fig = create_radar(
... data=pq_data,
... metrics=[
... "Copilot_actions_taken_in_Teams",
... "Collaboration_hours",
... "After_hours_collaboration_hours",
... "Internal_network_size",
... ],
... hrvar="Organization",
... )
Return the indexed table instead of a plot:
>>> tbl = create_radar(
... data=pq_data,
... metrics=["Collaboration_hours", "Meetings_count"],
... hrvar="Organization",
... return_type="table",
... )
Reference a specific group as 100 (ref_group indexing):
>>> fig = create_radar(
... data=pq_data,
... metrics=["Collaboration_hours", "Meetings_count"],
... hrvar="Organization",
... index_mode="ref_group",
... index_ref_group="Contoso Ltd",
... )
Min-max scaling to [0,100] within observed group ranges:
>>> fig = create_radar(
... data=pq_data,
... metrics=["Collaboration_hours", "Meetings_count", "Focus_hours"],
... hrvar="Organization",
... index_mode="minmax",
... )
- vivainsights.create_radar.create_radar_calc(data, metrics, hrvar, id_col='PersonId', mingroup=5, agg='mean', index_mode='total', index_ref_group=None, dropna=True)[source]¶
Name¶
create_radar_calc
Description¶
Compute group-level metric values and (optionally) index them for radar plotting.
- Steps:
Aggregate to person-level within each group (mean/median).
Aggregate the person-level values to the group level.
Enforce a minimum person count per group (mingroup).
Apply an indexing mode to make metrics comparable.
- param data:
Standard Person Query data frame containing metrics, hrvar, and id_col.
- type data:
pd.DataFrame
- param metrics:
Numeric metric column names to summarise and index for the radar chart.
- type metrics:
List[str]
- param hrvar:
HR attribute column identifying the group for each person (e.g., “Organization”, “LevelDesignation”).
- type hrvar:
str
- param id_col:
Column uniquely identifying people for person-level aggregation.
- type id_col:
str, default “PersonId”
- param mingroup:
Minimum number of unique people required in a group to retain it.
- type mingroup:
int, default 5
- param agg:
Aggregation function for both person-level and group-level summaries.
- type agg:
{“mean”,”median”}, default “mean”
- param index_mode:
“total”: index each metric vs. the overall person-level average (Total = 100).
“ref_group”: index vs. a specific group given by index_ref_group (Ref = 100).
“minmax”: scale to [0,100] within the min-max of observed group values (per metric).
“none”: return raw (unindexed) group values.
- type index_mode:
{“total”,”none”,”ref_group”,”minmax”}, default “total”
- param index_ref_group:
Required when index_mode=”ref_group”. Name of the group to serve as reference (=100).
- type index_ref_group:
Optional[str], default None
- param dropna:
If True, drop rows with NA in any of [id_col, hrvar] + metrics prior to aggregation.
- type dropna:
bool, default True
- returns:
(group_level_indexed, ref) –
- group_level_indexed
One row per group, wide across metrics. Values are indexed/scaled as per index_mode.
- ref
The reference used for indexing: - For “total” / “ref_group”: a pd.Series of reference means/medians. - For “minmax”: a two-column DataFrame with per-metric min and max. - For “none”: empty Series.
- rtype:
Tuple[pd.DataFrame, pd.Series]
- vivainsights.create_radar.create_radar_viz(data, metrics, hrvar, fill_missing='zero', figsize=(8, 6), title=None, subtitle=None, caption=None)[source]¶
Name¶
create_radar_viz
Description¶
Render a radar (spider) chart from a wide, group-level table produced by create_radar_calc. Each row in data is plotted as a polygon across the supplied metrics in the given order.
- param data:
One row per group, columns include hrvar and each of metrics. Values should already be indexed/scaled to comparable units (i.e. the output of create_radar_calc).
- type data:
pd.DataFrame
- param metrics:
Ordered list of metric columns to plot around the radar.
- type metrics:
List[str]
- param hrvar:
Column containing the group labels used in the legend.
- type hrvar:
str
- param fill_missing:
How to handle NA values in data before plotting: - “zero”: replace NA with 0 so polygons close correctly. - “none”: leave NA as-is (polygon may not render for that group).
- type fill_missing:
str, default “zero”
- param figsize:
Matplotlib figure size in inches (width, height).
- type figsize:
Tuple[float, float], default (8, 6)
- param title:
Top title for the figure.
- type title:
Optional[str], default None
- param subtitle:
Optional smaller line beneath the title (figure-level, not axes).
- type subtitle:
Optional[str], default None
- param caption:
Small text near the bottom of the figure (e.g., date range).
- type caption:
Optional[str], default None
- returns:
fig – The constructed matplotlib Figure.
- rtype:
matplotlib.figure.Figure
- vivainsights.create_radar.create_radar(data, metrics, hrvar='Organization', id_col='PersonId', mingroup=5, agg='mean', index_mode='total', index_ref_group=None, dropna=False, return_type='plot', figsize=(8, 6), title=None, subtitle=None, caption=None)[source]¶
Name¶
create_radar
Description¶
- High-level convenience wrapper to compute group-level metrics and either:
return the indexed table (return_type=”table”), or
render a radar chart (return_type=”plot”).
- param data:
Standard Person Query data frame containing at least metrics, id_col, and hrvar.
- type data:
pd.DataFrame
- param metrics:
Numeric metric columns to visualise (order determines the radar axes).
- type metrics:
List[str]
- param hrvar:
HR attribute column used for grouping (e.g., “Organization”, “LevelDesignation”).
- type hrvar:
str, default “Organization”
- param id_col:
Unique person identifier for person-level aggregation.
- type id_col:
str, default “PersonId”
- param mingroup:
Minimum unique person count per group.
- type mingroup:
int, default 5
- param agg:
Aggregation function for person- and group-level summaries.
- type agg:
{“mean”,”median”}, default “mean”
- param index_mode:
Indexing/scaling mode applied to group values prior to plotting.
- type index_mode:
{“total”,”none”,”ref_group”,”minmax”}, default “total”
- param index_ref_group:
Required when index_mode=”ref_group”. The name of the group that will be fixed at 100.
- type index_ref_group:
Optional[str], default None
- param dropna:
Drop rows with NA in required columns prior to aggregation.
- type dropna:
bool, default False
- param return_type:
“plot”: return a matplotlib Figure.
“table”: return the indexed group-level DataFrame.
- type return_type:
{“plot”,”table”}, default “plot”
- param figsize:
Figure size for the plot (ignored when return_type=”table”).
- type figsize:
Tuple[float, float], default (8, 6)
- param title:
Plot title. If None, a default title is inferred based on index_mode.
- type title:
Optional[str], default None
- param subtitle:
Optional subtitle line.
- type subtitle:
Optional[str], default None
- param caption:
Additional caption text appended after the auto-generated date range and index label, e.g. “caption” → “Data from … | Index: … | caption”. If None, only the date range and index label are shown.
- type caption:
Optional[str], default None
- returns:
If return_type=”plot”: a Figure containing the radar chart.
If return_type=”table”: the group-level indexed DataFrame.
- rtype:
matplotlib.figure.Figure or pd.DataFrame