# numpy.amax () in Python

NumPy | Python Methods and Functions

Parameters —

• arr: [array_like] input
• axis : axis [int or tuples of int] along which we want to get the maximum value. Otherwise, it will assume that arr will be flattened.
• from: [ndarray, optional] an alternative output array where to put the result
• keepdmis: [boolean, optional] if this parameter is set to True, the downsized axes remain in
the result as dimensions with size one. With this option, the result will translate correctly
the input array. If a default is passed, then keepdims will not be passed to all
ndarray subclasses, however any non-default will be. If the subclass sum method
does not implement keepdims, exceptions will be thrown.

Return — Maximum array — arr [ndarray or scalar], scalar if axis is None; The result is an array of dimensions a.ndim — 1 if axis is specified.

Code —

 ` # Python program illustrating ` ` # numpy.amax () method `   ` import ` ` numpy as geek `   ` # 1D array ` ` arr ` ` = ` ` geek.arange (` ` 8 ` `) ` ` print ` ` (` ` "arr:" ` `, arr) ` ` print ` ` (` ` " Max of arr: "` `, geek.amax (arr)) ` ` `  ` # 2D array ` ` arr ` ` = ` ` geek.arange (` ` 10 ` `). reshape (` ` 2 ` `, ` ` 5 ` ` ) ` ` print ` ` (` ` "arr:" ` `, arr) `   ` # Maximum smoothed array ` ` print ` ` (` ` "Max of arr, axis = None:" ` `, geek.amax (arr)) `   ` Maximum along the first axis ` ` # axis 0 means vertical ` ` print ` ` (` ` "Max of arr, axis = 0:" ` `, geek.amax (arr, axis ` ` = ` ` 0 ` `)) `   ` Second axis maximums ` ` # axis 1 means horizontal ` ` print ` ` (` ` "Max of arr, axis = 1: "` `, geek.amax (arr, axis ` ` = ` ` 1 ` `)) `

Exit —

` arr: [0 1 2 3 4 5 6 7] Max of arr: 7 arr: [[0 1 2 3 4] [5 6 7 8 9]] Max of arr, axis = None: 9 Max of arr, axis = 0: [5 6 7 8 9] Max of arr, axis = 1: [4 9] `

Note —
These codes will not work for online IDs. Please run them on your systems to see how they work