vivainsights.create_rank

Rank all groups across HR attributes for a selected Viva Insights metric.

vivainsights.create_rank.create_rank_calc(data, metric, hrvar=['Organization', 'FunctionType'], mingroup=5, stats=False)[source]

Compute ranked group averages across multiple HR attributes.

Used internally by create_rank.

Parameters:
  • data (pandas.DataFrame) – Person query data.

  • metric (str) – Name of the metric column.

  • hrvar (list of str, default ['Organization', 'FunctionType']) – HR attributes to rank across.

  • mingroup (int, default 5) – Minimum group size.

  • stats (bool, default False) – If True, include sd, median, min, and max columns.

Returns:

Ranked summary table sorted by descending metric mean.

Return type:

pandas.DataFrame

vivainsights.create_rank.create_rank_viz(data, metric, hrvar=['Organization', 'FunctionType', 'LevelDesignation', 'SupervisorIndicator'], mingroup=5, figsize=None)[source]

Create a dumbbell chart showing min/max groups per HR attribute.

Used internally by create_rank when return_type="plot".

Parameters:
  • data (pandas.DataFrame) – Person query data.

  • metric (str) – Name of the metric column.

  • hrvar (list of str) – HR attributes to rank across.

  • mingroup (int, default 5) – Minimum group size.

  • figsize (tuple or None, default None) – Figure size (width, height) in inches.

Returns:

The dumbbell chart figure.

Return type:

matplotlib.figure.Figure

vivainsights.create_rank.create_rank(data, metric, hrvar, mingroup=5, return_type='plot', figsize=None)[source]

Rank all groups across HR attributes for a selected metric.

Computes the mean of the metric for every level of each HR variable and displays the highest and lowest values in a dumbbell chart.

Parameters:
  • data (pandas.DataFrame) – Person query data.

  • metric (str) – Name of the metric to analyse.

  • hrvar (str or list of str) – One or more HR attributes to rank across.

  • mingroup (int, default 5) – Minimum group size.

  • return_type (str, default "plot") – "plot" for a matplotlib figure, "table" for a DataFrame.

  • figsize (tuple or None, default None) – Figure size (width, height) in inches. Defaults to (8, 6).

Returns:

A dumbbell chart or a ranked summary table.

Return type:

matplotlib.figure.Figure or pandas.DataFrame

Examples

Return a dumbbell chart (default):

>>> import vivainsights as vi
>>> pq_data = vi.load_pq_data()
>>> vi.create_rank(pq_data, hrvar=["FunctionType", "Organization"], metric="Emails_sent")

Return a ranked summary table:

>>> vi.create_rank(pq_data, hrvar=["FunctionType", "Organization"], metric="Emails_sent", return_type="table")

Customize figure size and minimum group size:

>>> vi.create_rank(
...     pq_data,
...     hrvar=["LevelDesignation", "Organization"],
...     metric="Collaboration_hours",
...     mingroup=10,
...     figsize=(10, 5),
... )