Categories
Python Answers

How to find the column name which has the maximum value for each row with Python Pandas?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *