vivainsights.create_boxplot

Create boxplot visualizations of metric distributions by organizational group.

The function create_boxplot creates a boxplot visualization and summary table for a given metric and grouping variable in a dataset.

vivainsights.create_boxplot.create_boxplot_calc(data, metric, hrvar, mingroup)[source]

Compute person-level metric averages per HR group.

Used internally by create_boxplot.

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

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

  • hrvar (str) – Name of the organizational attribute for grouping.

  • mingroup (int) – Minimum group size; groups below this threshold are dropped.

Returns:

Person-level averages with groups meeting the mingroup threshold.

Return type:

pandas.DataFrame

vivainsights.create_boxplot.create_boxplot_summary(data, metric, hrvar, mingroup)[source]

Return summary statistics for a metric by HR group.

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

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

  • hrvar (str) – Name of the organizational attribute for grouping.

  • mingroup (int) – Minimum group size.

Returns:

Summary table with mean, median, standard deviation, min, max, and count per group.

Return type:

pandas.DataFrame

vivainsights.create_boxplot.create_boxplot_viz(data, metric, hrvar, mingroup, figsize=None)[source]

Create a boxplot visualization of metric distributions by group.

Used internally by create_boxplot when return_type="plot".

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

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

  • hrvar (str) – Name of the organizational attribute for grouping.

  • mingroup (int) – Minimum group size.

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

Returns:

The boxplot figure.

Return type:

matplotlib.figure.Figure

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

Create a boxplot of metric distributions by organizational group.

Generates a boxplot showing the distribution of a selected metric across groups defined by an HR variable. Metrics are aggregated at the person level before plotting.

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

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

  • hrvar (str, default "Organization") – Name of the organizational attribute for grouping.

  • mingroup (int, default 5) – Minimum group size; smaller groups are excluded.

  • return_type (str, default "plot") – "plot" for a matplotlib figure, "table" for summary statistics, or "data" for the processed plot data.

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

Returns:

A boxplot figure, a summary table, or the processed data, depending on return_type.

Return type:

matplotlib.figure.Figure or pandas.DataFrame

Examples

Return a boxplot (default):

>>> import vivainsights as vi
>>> pq_data = vi.load_pq_data()
>>> vi.create_boxplot(pq_data, metric="Collaboration_hours", hrvar="Organization")

Return a summary table with mean, median, sd, min, max:

>>> vi.create_boxplot(pq_data, metric="Collaboration_hours", hrvar="Organization", return_type="table")

Return the processed person-level data:

>>> vi.create_boxplot(pq_data, metric="Collaboration_hours", hrvar="Organization", return_type="data")

Customize the figure size:

>>> vi.create_boxplot(
...     pq_data,
...     metric="Collaboration_hours",
...     hrvar="LevelDesignation",
...     figsize=(12, 8),
... )