I have a dataframe and i wanted a column filled with maximum value of each row so i used this :
df_1['Highest_Rew_patch'] = df_1.max(axis=1)
output:
Patch_0 Patch_1 Patch_2 ... Patch_7 exp_patch Highest_Rew_patch
0 0.0 70.0 70.0 ... 0.0 3 70.0
1 0.0 74.0 74.0 ... 0.0 4 74.0
2 0.0 78.0 78.0 ... 0.0 4 78.0
3 0.0 82.0 82.0 ... 0.0 4 82.0
4 0.0 82.0 82.0 ... 0.0 5 82.0
5 0.0 86.0 86.0 ... 0.0 6 86.0
6 0.0 90.0 90.0 ... 0.0 6 90.0
7 0.0 94.0 94.0 ... 0.0 6 94.0
8 0.0 98.0 98.0 ... 0.0 6 98.0
9 0.0 98.0 98.0 ... 0.0 7 98.0
However i want a little different result:
Patch_0 Patch_1 Patch_2 Patch_7 exp_patch Highest_Rew_patch
0 0.0 70.0 70.0 3 Patch_2,Patch_7...
1 0.0 74.0 74.0 4 Patch_2,Patch_7...
So instead of the highest value of the row , i want the header of that column for that particular row which has highest value(s).