Index Class 1 Class 2 Class 3 Class 4 Class 5
0 0.95693475 0.252198994 0.0 0.335894585 0.611441553
1 0.473615974 0.0 0.510585248 0.5007305 0.975620011
2 0.224682823 0.122315248 0.6407305 0.0 0.872211390
This is a sample of the dataframe I am working on. I have around 200 Class's in my original dataframe and around 85000 rows and for each row of my dataframe I want to find out the top 3 Categories with their values sorted in descending order:
Expected output:
Row 0: [{Class 1 : 95693475}, {Class 5: 0.611441553}, {Class 4: 0.335894585}]
Row 1: [{Class 5 : 0.975620011}, {Class 3: 0.510585248}, {Class 4: 0.5007305}]
etc etc...
Note: List and dict in the expected output are just added for reference, just need to output the top 3 scores with their category names for each row in the dataframe. Can anyone help me with this