Search code examples
pythonpandasdataframemaxmin

How to find the max, min value of ALL Dataframe [ not values by column neither rows ]


I know how to find in a Dataframe the max and minimum value of a column:

df.min()
df.max()

If I want to find the min and max values by row is:

df.max(index=1)
df.max(index=1)

But this return a list with the respective row or column value. I want to find the minimum or maximum value of all the dataset, only one value.

I was thinking try to iterate by row and column finding the max value But I see here that this is anti-pattern for pandas.

I am thinking in a function that only output me a value with the respective location. This function exist or I need to create?

I research answer here and not find anything related.


Solution

  • You can try:

    max_val = df.max().max()