I have a table like this,
Hour represents the hour of the day agent reached the customer successfully.
Cus1 to Cus4 are the top 4 time slots provided to the agent to call the customer.
Cus1_Score to Cus4_Score represents the probability of success for the call during the hours corresponding to Cus1 to Cus4.
I need to get YES or NO values for Match1 and Match2 columns.
Match1 represents this - Check for the highest score in the columns Cus1_Score to Cus4_Score. If no duplicates, check if Cus1 = Hour and if it's a match we write YES else NO. If duplicates exist, check all the columns with highest score and and check if the Hour number matches to any of the values in the high score represented Cus columns(Cus1 to Cus4). Again, if it's match YES else NO.
Match2 represents this - Check for the second highest score in the columns Cus1_Score to Cus4_Score. If no duplicates, check if Cus2 = Hour and if it's a match we write YES else NO. If duplicates exist, check all the columns with second highest score and and check if the Hour number matches to any of the values in the second high score represented Cus columns(Cus1 to Cus4). Again, if it's match YES else NO.
ID Hour Cus1 Cus2 Cus3 Cus4 Cus1_Score Cus2_Score Cus3_Score Cus4_Score Match1 Match2
1 11 8 10 11 14 0.62 0.59 0.59 0.54 NO YES
2 13 15 16 18 13 0.57 0.57 0.57 0.57 YES NO
3 16 09 14 16 12 0.67 0.54 0.48 0.34 NO NO
4 08 11 08 12 17 0.58 0.55 0.43 0.25 NO YES
I tried using idxmax() and nlargest(2) functions and I have no luck as I am not very strong in Python. Highly appreciate your help.