[Tutor] maximum value in a Numeric array

Ertl, John john.ertl at fnmoc.navy.mil
Fri Dec 10 22:36:49 CET 2004


Thanks for the help...I am using the older Numeric 23.4.  I have some stuff
that cannot use Numarray yet.  Numeric does not seam to have the same

Happy Holidays.

John Ertl

-----Original Message-----
From: Danny Yoo [mailto:dyoo at hkn.eecs.berkeley.edu]
Sent: Friday, December 10, 2004 11:26
To: Ertl, John
Cc: tutor at python.org
Subject: Re: [Tutor] maximum value in a Numeric array

On Fri, 10 Dec 2004, Ertl, John wrote:

> I am trying to get the maximum value in a 2-D array.  I can use max but
> it returns the 1-D array that the max value is in and I then I need to
> do max again on that array to get the single max value.
> There has to be a more straightforward way...I have just not found it.
> >>> b = array([[1,2],[3,4]])
> >>> max(b)
> array([3, 4])
> >>> c = max(b)
> >>> max(c)
> 4

Hi John,

According to:


you can use the 'max()' method of an array:

>>> import numarray
>>> b = numarray.array([[1,2],[3,4]])
>>> b.max()

Hope this helps!

More information about the Tutor mailing list