I have dataframe that looks like:
Alice Eleonora Mike Helen
2 7 8 6
11 5 9 4
6 15 12 3
5 3 7 8
I want ot create the new column that containes for each row the name of the column with max value for given row
Alice Eleonora Mike Helen _Max
2 7 8 6 Mike
11 5 9 4 Alice
6 15 12 3 Eleonora
5 3 7 8 Helen
I figure out how to get the max value:
df['_Max']=df[['Alice', 'Eleonora', 'Mike', 'Helen']].max(axis=1)
but how to get the name of column with max value and write it into _Max
instead of value itself?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…