# NumPy - amax() function

The NumPy amax() function returns the maximum of an array or maximum along the specified axis.

### Syntax

```numpy.amax(a, axis=None, out=None, keepdims=<no value>)
```

### Parameters

 `a` `Required. `Specify the input array. `axis` `Optional. `Specify axis or axes along which to operate. The default, axis=None, operation is performed on flattened array. `out` `Optional. `Specify the output array in which to place the result. It must have the same shape as the expected output. `keepdims` `Optional. `If this is set to True, the reduced axes are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

### Return Value

Returns maximum of a. If axis is None, the result is a scalar value. If axis is given, the result is an array of dimension a.ndim - 1.

### Example: amax() of flattened array

In the example below, amax() function is used to return the maximum of all values present in the array.

```import numpy as np
Arr = np.array([[10,20],[30, 40]])

print("Array is:")
print(Arr)

#maximum of all values
print("\nMaximum of all values:", np.amax(Arr))
```

The output of the above code will be:

```Array is:
[[10 20]
[30 40]]

Maximum of all values: 40
```

### Example: amax() with axis parameter

When axis parameter is provided, maximum is calculated over the specified axes as shown in the example below.

```import numpy as np
Arr = np.array([[10,20,30],[70,80,90]])

print("Array is:")
print(Arr)

#maximum along axis=0
print("\nMaximum along axis=0")
print(np.amax(Arr, axis=0))

#maximum along axis=1
print("\nMaximum along axis=1")
print(np.amax(Arr, axis=1))
```

The output of the above code will be:

```Array is:
[[10 20 30]
[70 80 90]]

Maximum along axis=0
[70 80 90]

Maximum along axis=1
[30 90]
```

❮ NumPy - Functions

5