Skip to content
Advertisement

Max and Min value for each colum of one Dataframe

Give this dataframe ‘x’:

JavaScript

How I could get a list of pairs with the min and max of each column? The result would be:

JavaScript

Advertisement

Answer

You could define a function and call apply passing the function name, this will create a df with min and max as the index names:

JavaScript

If you insist on a list of lists we can transpose the df and convert the values to a list:

JavaScript

The function itself is not entirely necessary as you can use a lambda instead:

JavaScript

Note also that you can use describe and loc to get what you want:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement