vivainsights.hrvar_count

Count the number of distinct persons by organizational group.

Returns a bar plot of the counts by default, with an option to return a summary table.

vivainsights.hrvar_count.hrvar_count_calc(data, hrvar)[source]

Calculate the number of distinct persons in the data population, grouped by a selected HR variable.

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

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

Returns:

Summary table with unique person count per group.

Return type:

pandas.DataFrame

Examples

>>> import vivainsights as vi
>>> pq_data = vi.load_pq_data()
>>> vi.hrvar_count_calc(pq_data, hrvar="Organization")
vivainsights.hrvar_count.hrvar_count_viz(data, hrvar, figsize=None)[source]

Visualise the number of distinct persons in the data population, grouped by a selected HR variable.

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

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

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

Returns:

The bar chart figure.

Return type:

matplotlib.figure.Figure

Examples

>>> import vivainsights as vi
>>> pq_data = vi.load_pq_data()
>>> vi.hrvar_count_viz(pq_data, hrvar="Organization")
vivainsights.hrvar_count.hrvar_count_all(data, hrvar_list=None, max_unique=50)[source]

Create a summary table to validate organizational data.

Returns the count of distinct fields per HR attribute and the percentage of employees with missing values for that attribute.

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

  • hrvar_list (list of str, optional) – HR variables to analyze. If None, uses extract_hr() to dynamically identify organizational attributes.

  • max_unique (int, optional) – Maximum number of unique values for a column to be considered an HR variable (only used when hrvar_list is None). Defaults to 50.

Returns:

Summary table with columns hrvar, distinct_values, missing_count, and missing_percentage.

Return type:

pandas.DataFrame

Examples

>>> import vivainsights as vi
>>> pq_data = vi.load_pq_data()
>>> vi.hrvar_count_all(pq_data)
>>>
>>> vi.hrvar_count_all(pq_data, max_unique=100)
vivainsights.hrvar_count.hrvar_count(data, hrvar='Organization', figsize=None, return_type='plot')[source]

Count distinct persons in the data population grouped by an HR variable.

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

  • hrvar (str) – Organizational attribute for grouping. Defaults to "Organization".

  • figsize (tuple, optional) – Figure size as (width, height) in inches. Defaults to (8, 6).

  • return_type (str) – "plot" (default) returns a bar chart; "table" returns a summary DataFrame.

Returns:

Bar chart or summary table depending on return_type.

Return type:

matplotlib.figure.Figure or pandas.DataFrame

Examples

Return a bar chart (default):

>>> import vivainsights as vi
>>> pq_data = vi.load_pq_data()
>>> vi.hrvar_count(pq_data, hrvar="LevelDesignation")

Return a summary table:

>>> vi.hrvar_count(pq_data, hrvar="Organization", return_type="table")

Customize figure size:

>>> vi.hrvar_count(pq_data, hrvar="LevelDesignation", figsize=(10, 5))