vivainsights.identify_tenure

Calculate and summarize employee tenure based on hire and metric dates.

The identify_tenure function provides various options for returning the results.

vivainsights.identify_tenure.identify_tenure(data, beg_date='HireDate', end_date='MetricDate', maxten=40, return_type='message', date_format='%Y-%m-%d')[source]

Calculate and summarize employee tenure.

Computes tenure in years from hire date to the latest metric date and provides diagnostics, plots, or filtered datasets.

Parameters:
  • data (pandas.DataFrame) – Person query data. Must include columns for hire and metric dates.

  • beg_date (str, default "HireDate") – Column name for the hire date.

  • end_date (str, default "MetricDate") – Column name for the end / metric date.

  • maxten (int, default 40) – Maximum tenure threshold in years. Employees at or above this value are flagged.

  • return_type (str, default "message") – "message" prints a summary, "text" returns it as a string, "plot" displays a density curve, "data_cleaned" removes flagged employees, "data_dirty" keeps only flagged employees, "data" returns per-person tenure.

  • date_format (str, default "%Y-%m-%d") – strftime format of dates in the date columns.

Returns:

A printed message, string, density plot, or DataFrame depending on return_type.

Return type:

None, str, pandas.DataFrame, or matplotlib plot

Examples

Return a text summary of tenure distribution:

>>> import vivainsights as vi
>>> pq_data = vi.load_pq_data()
>>> vi.identify_tenure(pq_data, return_type="text")

Return a density plot of tenure:

>>> vi.identify_tenure(pq_data, return_type="plot")

Return the dataset with a computed tenure column:

>>> vi.identify_tenure(pq_data, return_type="data")

Return only rows with short tenure (below threshold):

>>> vi.identify_tenure(pq_data, maxten=40, return_type="data_cleaned")

Specify custom date column names:

>>> vi.identify_tenure(pq_data, beg_date="HireDate", end_date="MetricDate", return_type="text")