Skip to content

Commit

Permalink
Merge pull request #22 from jrasband-dev/0.5.0
Browse files Browse the repository at this point in the history
docs: Added Documentation for human capital metrics
  • Loading branch information
jrasband-dev authored Sep 25, 2024
2 parents 8bf1e1a + d69b95d commit de371ca
Show file tree
Hide file tree
Showing 11 changed files with 1,548 additions and 1,653 deletions.
110 changes: 0 additions & 110 deletions docs/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
project = 'Metric Forge'
copyright = '2024, Jayden Rasband'
author = 'Jayden Rasband'
release = '0.3.0'
release = '0.5.0'

# -- General configuration ---------------------------------------------------

Expand Down
62 changes: 61 additions & 1 deletion metric_forge/human_capital/polars_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,84 @@ def __init__(self, expr: pl.Expr):

# Employee Turnover Rate
def employee_turnover_rate(self, employees_left_column: str, total_employees_column: str) -> pl.Expr:
'''
Calculates the employee turnover rate by dividing the number of employees who have left by the total number of employees.
Parameters
----------
employees_left_column : str
The column name representing the number of employees who have left during a given period.
total_employees_column : str
The column name representing the total number of employees during the same period.
Returns
-------
pl.Expr
An expression representing the employee turnover rate, set to 0 if the total number of employees is zero.
'''
employees_left_expr = pl.col(employees_left_column)
total_employees_expr = pl.col(total_employees_column)
return pl.when(total_employees_expr == 0).then(0.0).otherwise(employees_left_expr / total_employees_expr).alias('employee_turnover_rate')

# Sales per Employee
def sales_per_employee(self, sales_column: str, total_employees_column: str) -> pl.Expr:
'''
Calculates the sales per employee by dividing total sales by the number of employees.
Parameters
----------
sales_column : str
The column name representing the total sales over a given time period.
total_employees_column : str
The column name representing the total number of employees during the same period.
Returns
-------
pl.Expr
An expression representing sales per employee, set to 0 if the total number of employees is zero.
'''
sales_expr = pl.col(sales_column)
total_employees_expr = pl.col(total_employees_column)
return pl.when(total_employees_expr == 0).then(0.0).otherwise(sales_expr / total_employees_expr).alias('sales_per_employee')

# Absenteeism Rate
def absenteeism_rate(self, absent_days_column: str, total_workdays_column: str) -> pl.Expr:
'''
Calculates the absenteeism rate by dividing the number of absent days by the total number of workdays.
Parameters
----------
absent_days_column : str
The column name representing the number of days employees were absent.
total_workdays_column : str
The column name representing the total number of workdays in a given period.
Returns
-------
pl.Expr
An expression representing the absenteeism rate, set to 0 if the total number of workdays is zero.
'''
absent_days_expr = pl.col(absent_days_column)
total_workdays_expr = pl.col(total_workdays_column)
return pl.when(total_workdays_expr == 0).then(0.0).otherwise(absent_days_expr / total_workdays_expr).alias('absenteeism_rate')

# Average Tenure of Employees
def average_tenure(self, total_tenure_column: str, total_employees_column: str) -> pl.Expr:
total_tenure_expr = pl.col(total_tenure_column) # Assumes total tenure in years or months
'''
Calculates the average tenure of employees by dividing the total tenure by the total number of employees.
Parameters
----------
total_tenure_column : str
The column name representing the total tenure of employees, typically in years or months.
total_employees_column : str
The column name representing the total number of employees.
Returns
-------
pl.Expr
An expression representing the average tenure of employees, set to 0 if the total number of employees is zero.
'''
total_tenure_expr = pl.col(total_tenure_column)
total_employees_expr = pl.col(total_employees_column)
return pl.when(total_employees_expr == 0).then(0.0).otherwise(total_tenure_expr / total_employees_expr).alias('average_tenure')
Loading

0 comments on commit de371ca

Please sign in to comment.