user308827
user308827

Reputation: 22031

Pandas pivot table maximum value

I have the following pivot table (df):

Region     North      South
Col                                
A          33.330367   9.178917
B         -36.157025  -27.669988
C         -38.480206  -46.089908
D         -47.986764  -32.324991
E          323.209834  28.486310
F          34.936147   4.072872
G          0.983977   -14.972555

In order to find the maximum value, I do:

df.max()

It returns:

Region
North     323.209834
South      28.486310
dtype: float64

Is there a way to just return the maximum value i.e. 323?

Upvotes: 0

Views: 2480

Answers (1)

YS-L
YS-L

Reputation: 14748

You can use max() twice:

df.max().max()

Alternatively, since we are already assuming that all the elements are numerical, we can get the underlying numpy array and thus its maximum value using a single call to max():

df.values.max()

Upvotes: 1

Related Questions