dimanche 5 novembre 2017

Generate random number (salaries) based on job titles in Python

Is there any way to generate random numbers (salaries) based on the job title. For example applying weights based in job title. Currently I am doing the following

import numpy as np 
from random import randint

job_titles = ['developer','business manager','staff','senior developer']
title = np.random.choice(office_titles, 1, p=[0.4, 0.1, 0.4, 0.1])[0]
if title == 'developer': salary = randint(40000,55000)
elif title == 'business manager': salary = randint(70000,85000)
elif title == 'staff': salary = randint(25000,45000)
else: salary = randint(55000,75000)

In my case I have almost 30 job titles and it is not a good way of solving this issue. Can any some guide me what is the efficient way of doing this ?




Aucun commentaire:

Enregistrer un commentaire