I have a sales dataframe with customer data and sales team. I have a target calls based on the individual customer which I want to split across the sales teams
cust_id| total_calls_req| group_1_rep| group_2_rep| group_3_rep
34523 | 10 | 230429 | nan | 583985
34583 | 12 | 230429 | 539409 | 583985
34455 | 6 | 135552 | nan | nan
I want to create a function that splits the total_calls_req
across each group based on whether or not there is a group_rep assigned.
If cust_id
is assigned to 1 rep then the total_calls_req
is all assigned to the rep in question
If cust_id
is assigned to 2 reps then the total_calls_req
is split between the two reps in question.
If cust_id
is assigned to 3 reps then the total_calls_req
is split randomly between the three reps in question and needs to be whole cards.
I want the end dataframe to look like this:
cust_id| total_calls_req| group_1_rep| group_2_rep| group_3_rep| group_1_rep_calls| group_2_rep_calls| group_3_rep_calls
34523 | 10 | 230429 | nan | 583985 | 5 | 0 | 5
34583 | 12 | 230429 | 539409 | 583985 | 6 | 3 | 3
34455 | 6 | 135552 | nan | nan | 6 | 0 | 0
Is there a way I can do that through a python function?