To find the column name which has the maximum value for each row with Python Pandas, we can use the idxmax
method.
For instance, we write
df.idxmax(axis=1)
to call idxmax
with axis
set to 1 to return the column with the great value on each row.