I've a dataframe that contains normalized values. From each row I can obtain the maxvalue, but now I want to get also the corresponding column names.
For example df:
|----------------------------------------|
| a | b | c | 'newcol' |
|----------------------------------------|
| 0.960 | 1.00 | 1.00 | b, c |
|----------------------------------------|
| 0.922 | 0.955 | 0.971 | c |
|----------------------------------------|
So i want to create this newcol containing the column names that have the max values.
I've tried df.idxmax(axis=1) however this returns only the first column with the max value
Find all indices of maximum in Pandas DataFrame Tries to solve the same problem however the data is stored in a list instead of a new column in same df