I have a dataframe that has a department, its function, its subfunction and its sub-subfunction. A example of the dataframe would be this:
Department Function Subfunction Sub-subfunction
0 Dept1 HR HR Talent HR Talent 3
1 Dept2 IT Analysis HR Analysis HR 2
2 Dept3 IT IT Support IT Tech 2
3 Dept4 HR IT Tech HR Talent 1
4 Dept5 MKT IT Support MKT Strategy 2
5 Dept6 MKT MKT Comm MKT Comm2
I need to create a rule that would check if a department has a certain value in function, it only allow a possible list of values in subfunction. Then, in subfunction the same, each unique value would allow only a possible list of values in sub-subfunction.
It would work Like this:
- If the value in Function is HR, then the value accepted for Subfunction would be only the ones related to HR. Same for Marketing and IT.
- If the sunfunction then is correct, it would check if the sub-subfunction is valid (let's say that each subfunction can have their break down into 1, 2 and 3). So if, for example, the subfunction is "HR Talent", the sub-subfunction would only accept "HR Talent 1", "HR Talent 2" and "HR Talent 3".
In this dataframe, this function would return the ones that do not obey this rule, in this example it would return:
Department Function Subfunction Sub-subfunction
1 Dept2 IT Analysis HR Analysis HR 2
2 Dept3 IT IT Support IT Tech 2
3 Dept4 HR IT Tech HR Talent 1
4 Dept5 MKT IT Support MKT Strategy 2
What would be the best way to apply those rules?
Thank you for the support!
Aucun commentaire:
Enregistrer un commentaire