# Python: Get the Maximum value in a NumPy Array To get the maximum value of all the elements in a NumPy array, use the `numpy.max()` function. Pass the array to evaluate as the first argument of the function and store the result in a variable.

## Syntax

Here is the syntax of the `.max()` function from the NumPy Python package:

``````max_val = numpy.max(arr)
``````

## NumPy Array Max Value Example

To demonstrate how this works, let's create a NumPy array with random number data, find the maximum value then print the result.

``````import numpy as np

arr = np.random.randint(9, size=(3,4))

max_val = np.max(arr)

print('Max value: ', max_val)

print('Array: \n', arr)
``````
``````Max value:  8
Array:
[[5 7 6 2]
[5 8 2 2]
[6 7 0 1]]
``````

Note – the above method will work for both integers and floating-point numbers.

#### Related Tutorials ### Python Numpy.sqrt() - Square Root

June 30, 2021 ### How to Replace NA or NaN Values in Pandas DataFrame with fillna()

June 10, 2021 ### Calculate Euclidean Distance in Python

October 01, 2021 ### Find Maximum Value in a List in Python

September 22, 2021 ### Element-Wise Multiplication in NumPy

September 26, 2021 May 12, 2021