mardi 27 avril 2021

Pandas - find value in column based on values from another column and replace date in different column

I have a df that looks like below:

ID    Name      Supervisor         SupervisorID
1     X         Y                  
2     Y         C                  
3     Z         Y                  
4     C         Y                  
5     V         X                  

What I need is to find SupervisorID. I can find his ID by checking it in column Name and that I will see his ID so if supervisor is Y then I see that in column Name there is Y so his ID id 2. DF should looks like below:

ID    Name      Supervisor         SupervisorID
1     X         Y                  2
2     Y         C                  4
3     Z         Y                  2
4     C         Y                  2
5     V         X                  1

Do you have any idea how to solve this?

Thanks for help and best regards

Aucun commentaire:

Enregistrer un commentaire