def count_per_month(career_months_array):
'''Month_Form
Returns number of employees remaining for each month (not retired).
Cumulative sum of career_months_array input (np array) that are
greater or equal to each incremental loop month number.
Note: alternate method to this function is value count of mnums:
df_actives_each_month = pd.DataFrame(df_idx.mnum.value_counts())
df_actives_each_month.columns = ['count']
input
career_months_array
output of career_months function. This input is an array
containing the number of months each employee will work until
retirement.
'''
max_career = career_months_array.max() + 1
emp_count_array = np.zeros(max_career)
for i in range(0, max_career):
emp_count_array[i] = np.count_nonzero(career_months_array >= i)
return emp_count_array.astype(int)
# GENERATE MONTH SKELETON
评论列表
文章目录