Python 3 | Pandas DataFrame | Finding rows of Maximum value for each Columns in Pandas using .idxmax()

Python Pandas DataFrame .idxmax get row of maximum value
In order to get rows or row IDs of Dataframe having maximum values for each column, Pandas DataFrame’s .idxmax() is used.

.idxmax() returns Row Ids of Maximum values of each column of a DataFrame.

We are not using .max() here because .max() returns the actual value rather then the row in which that value resides. At times it’s useful to have a look at the whole row of a DataFrame where a column’s max value is present. Thats where .idxmax() is useful.

DataFrame.idxmax(axis=0, skipna=True)

Parameters :
axis : 0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise
skipna : Exclude NA/null values. If an entire row/column is NA, the result will be NA

Returns : idxmax : Series

Following is the code with comments, description and results of the commands to be run in Python 3 for using .idxmax() to get row ids of maximum values for each column:

Please follow and like us:

Leave a Reply

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