numpy.amax() in Python Last Updated : 28 Apr, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The numpy.amax() method returns the maximum of an array or maximum along the axis(if mentioned). Syntax: numpy.amax(arr, axis = None, out = None, keepdims = <class numpy._globals._NoValue>) Parameters - arr : [array_like] input dataaxis : [int or tuples of int] axis along which we want the max value. Otherwise, it will consider arr to be flattened.out : [ndarray, optional] alternative output array in which to place the resultkeepdims : [boolean, optional] if this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the all method of sub-classes of ndarray, however any non-default value will be. If the sub-classes sum method does not implement keepdims any exceptions will be raised. Return - Maximum of array - arr[ndarray or scalar], scalar if axis is None; the result is an array of dimension a.ndim - 1, if axis is mentioned. Code - Python # 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("\narr : ", arr) # Maximum of the flattened array print("\nMax of arr, axis = None : ", geek.amax(arr)) # Maxima along the first axis # axis 0 means vertical print("Max of arr, axis = 0 : ", geek.amax(arr, axis = 0)) # Maxima along the second axis # axis 1 means horizontal print("Max of arr, axis = 1 : ", geek.amax(arr, axis = 1)) Output - 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] Reference - https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.amax.html Note - These codes won't run on online IDE's. So please, run them on your systems to explore the working. Comment More infoAdvertise with us Next Article numpy.amax() in Python M Mohit Gupta Improve Article Tags : Python Practice Tags : python Similar Reads NumPy Array in Python NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C 2 min read numpy.alen() in Python numpy.alen() function is used to return the length of the first dimension of the input array. Syntax : numpy.alen(arr) Parameters : arr : [array_like] Input array. Return : [int]Length of the first dimension of arr. Code #1 : Python3 # Python program explaining # alen() function import numpy as geek 1 min read numpy.asarray() in Python numpy.asarray()function is used when we want to convert input to an array. Input can be lists, lists of tuples, tuples, tuples of tuples, tuples of lists and arrays. Syntax : numpy.asarray(arr, dtype=None, order=None) Parameters : arr : [array_like] Input data, in any form that can be converted to a 2 min read numpy.asscalar() in Python numpy.asscalar() function is used when we want to convert an array of size 1 to its scalar equivalent. Syntax : numpy.asscalar(arr) Parameters : arr : [ndarray] Input array of size 1. Return : Scalar representation of arr. The output data type is the same type returned by the inputâs item method. Co 1 min read numpy.asanyarray() in Python numpy.asanyarray()function is used when we want to convert input to an array but it pass ndarray subclasses through. Input can be scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists and ndarrays. Syntax : numpy.asanyarray(arr, dtype=None, order=None) Parameters : arr : [array_ 2 min read Like