NumPy arrays have many functions that can be applied to the arrays. Many of these are statistical functions that you can use for data analysis. The following example describes several of the useful functions.
Note
Note that most of these functions work on multi-dimensional arrays, and the axis to which the function is applied to is specified by the axis
parameter. We will examine this for the .min()
and .max()
functions, but note that the axis
parameter applies to many other NumPy functions.
The .min()
and .max()
methods return the minimum and maximum values in an array. The .argmax()
and .argmin()
functions return the position of the maximum or minimum value in the array:
In [82]: # demonstrate some of the properties of NumPy arrays m = np.arange(10, 19).reshape(3, 3) print (a) print ("{0} min of the entire matrix".format(m.min())) print ("{0} max of entire matrix".format(m.max())) print ("{0} position of the min value".format(m.argmin...