Find the max or min index/column for the overall pandas dataframe

Hi,

There are functions that returns the index of the max/min in a pandas column, or the column of the max/min in a pandas row, like “idxmax” or “idxmin”

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.idxmax.html

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.idxmin.html

Is there a function that returns the index and the column of the max/min of the “overall dataframe”?

For example, I’d like to have ['Beef' , 'co2_emissions' ] since 1712.00 is the maximum in the overall dataframe.

df
                consumption  co2_emissions
Pork                  10.51         37.20
Wheat Products       103.11         19.66
Beef                  55.48       1712.00

Thanks!

Not that I am aware of. But you can do this:

df.stack().idxmax()
('Beef', 'co2_emissions')
1 Like