I have a dataframe as given below.My objective is that for each pf_customer_id I would require the top 5 columns (from highest to lowest).I tried using group by and doing transpose however filtering the highest 5 column is a challenge.
{'A': {0: 0.0, 1: 1916.714416, 2: 4022.357547, 3: 6275.28689, 4: 582.863581},
'B': {0: 1916.714416, 1: 0.0, 2: 2105.715414, 3: 4358.78689, 4: 2499.358343},
'C': {0: 4022.357547, 1: 2105.715414, 2: 0.0, 3: 2253.29093, 4: 4604.71567},
'D': {0: 6275.28689, 1: 4358.78689, 2: 2253.29093, 3: 0.0, 4: 6857.928954},
'E': {0: 582.863581, 1: 2499.358343, 2: 4604.71567, 3: 6857.928954, 4: 0.0},
'F': {0: 970.716604,
1: 2887.214892,
2: 4992.857468,
3: 7245.929486,
4: 388.227816},
'G': {0: 1235.716107,
1: 3152.215475,
2: 5257.785928,
3: 7510.859423,
4: 653.301411},
'H': {0: 6508.144182,
1: 4591.6443,
2: 2486.290843,
3: 233.217505,
4: 7090.928801},
'I': {0: 3256.328289,
1: 1340.025712,
2: 766.557835,
3: 3019.314118,
4: 3838.883097},
'J': {0: 2698.412148,
1: 782.275937,
2: 1324.562498,
3: 3577.356653,
4: 3281.013733},
'K': {0: 3147.725445,
1: 1231.310389,
2: 874.905741,
3: 3127.932009,
4: 3730.362069},
'L': {0: 3116.819967,
1: 1200.43964,
2: 905.919746,
3: 3158.947766,
4: 3699.30572},
'M': {0: 1904.334099,
1: 18.283597,
2: 2118.335643,
3: 4371.368639,
4: 2486.953355},
'N': {0: 2353.462836,
1: 436.955498,
2: 1669.340686,
3: 3922.224931,
4: 2935.946158},
'O': {0: 2913.365253,
1: 996.876837,
2: 1109.455848,
3: 3362.429984,
4: 3495.788897},
'P': {0: 2157.443161,
1: 242.20937,
2: 1865.553245,
3: 4118.418641,
4: 2739.958665},
'pf_customer_id': {0: 60000, 1: 60001, 2: 60002, 3: 60003, 4: 60004}}
Expected output is shown below. Just taking an instance of two customer ID to make it more easy to understand: