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


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”

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.

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


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

('Beef', 'co2_emissions')
1 Like

After you make your dataframe do this:

import pandas
        df=pandas.DataFrame(outdata, columns=['Hdr1', 'Hdr2', 'Hdr3']) # Make a dataframe from the list of lists. 
    except ValueError as e: 
        sys.exit(f"{procname} ERROR-dataframe1: Num headers does not match num columns.")
    except Exception as e: 
        sys.exit(f"{procname} ERROR-dataframe2: {e}")
    (numrows, numcols) = df.shape # Max number of rows and columns returned as a tuple.