Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the maximum value of the whole dataframe in pandas

I already sorted the data and the dataframe now is like this:

              Tr Srate(V/ns)mean  Tf Srate(V/ns)mean
CPULabel                                            
100HiBW_Fast                3.16                3.09
100LoBW_Fast                3.16                3.09
BP100_Fast                  3.16                3.06

My dataframe is slew_rate_max. I tried to use:

slew_rate_max.max()

I expected the result to be 3.16. However, I got the max values of both columns individually.

Tr Srate(V/ns)mean    3.16
Tf Srate(V/ns)mean    3.09
dtype: float64

How to get the max value of the whole dataframe not of each column?

like image 256
Dogod Avatar asked Jun 22 '17 22:06

Dogod


Video Answer


1 Answers

Try:

slew_rate_max.max().max()

slew_rate_max.max() returns a series with the max of each column, then taking the max again of that series will give you the max of the entire dataframe.

or

slew_rate_max.values.max()

slew_rate_max.values converts the dataframe to a np.ndarray then using numpy.ndarray.max which as an argument axis that the default is None, this gives the max of the entire ndarray.

like image 53
Scott Boston Avatar answered Sep 20 '22 16:09

Scott Boston