🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.max.html
numpy.max — NumPy v2.2 Manual
numpy.max(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[source]#
Learn
This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference · This set of tutorials and educational materials is being developed in the numpy-tutorials repository, and is not a part of the NumPy source tree. The goal of this repository is to provide ...
User Guide
Fundamentals and usage · Advanced usage and interoperability
Linear algebra (numpy.linalg)
The NumPy linear algebra functions rely on BLAS and LAPACK to provide efficient low level implementations of standard linear algebra algorithms. Those libraries may be provided by NumPy itself using C versions of a subset of their reference implementations but, when possible, highly optimized ...
numpy.hypot
Given the “legs” of a right triangle, return its hypotenuse · Equivalent to sqrt(x1**2 + x2**2), element-wise. If x1 or x2 is scalar_like (i.e., unambiguously cast-able to a scalar type), it is broadcast for use with each element of the other argument. (See Examples)
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.ndarray.max.html
numpy.ndarray.max — NumPy v2.5 Manual
ndarray.max(axis=None, out=None, *, keepdims=<no value>, initial=<no value>, where=<no value>)# Return the maximum along a given axis. Refer to numpy.amax for full documentation. See also · numpy.amax · equivalent function ·
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.max.html
numpy.max — NumPy v2.6.dev0 Manual
numpy.max(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[source]#
🌐
Programiz
programiz.com › python-programming › numpy › methods › max
NumPy max()
numpy.max(array, axis = None, out = None, keepdims = <no value>, initial=<no value>, where=<no value>)
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.argmax.html
numpy.argmax — NumPy v2.6.dev0 Manual
Array of indices into the array. It has the same shape as a.shape with the dimension along axis removed. If keepdims is set to True, then the size of axis will be 1 with the resulting array having same shape as a.shape. ... The maximum value along a given axis.
🌐
DataCamp
datacamp.com › doc › numpy › max
NumPy max()
Set `keepdims=True` if you need the result to maintain the original number of dimensions. Combine with boolean indexing. Use `np.max()` in combination with boolean conditions to find maximums in filtered subsets of data.
🌐
Sharp Sight
sharpsight.ai › blog › numpy-max
How to use the NumPy max function - Sharp Sight
February 6, 2024 - But if you set keepdims = True, the output will have the same dimensions as the input. This is a little abstract without a concrete example, so I’ll show you an example of this behavior later in the examples section.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.max.html
numpy.max — NumPy v2.1 Manual
numpy.max(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[source]#
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.max.html
numpy.max — NumPy v2.5 Manual
numpy.max(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[source]#
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.amax.html
numpy.amax — NumPy v2.5 Manual
numpy.amax(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[source]# Return the maximum of an array or maximum along an axis.
Find elsewhere
🌐
Plus2Net
plus2net.com › python › numpy-agg-max.php
Numpy aggregate functions max to get highest of elements with different options
numpy.max(a,axis=None,out=None,keepdims, initial, where) Return highest of elements across given axis.
🌐
Tutorial Gateway
tutorialgateway.org › python-numpy-max
Python numpy max
September 18, 2022 - numpy.max(a, axis = None, out = None, keepdims = <no value>, initial = <no value>, where = <no value>)
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.max.html
numpy.max — NumPy v2.3 Manual
numpy.max(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[source]#
🌐
NumPy
numpy.org › devdocs › reference › generated › numpy.ndarray.max.html
numpy.ndarray.max — NumPy v2.6.dev0 Manual
ndarray.max(axis=None, out=None, *, keepdims=<no value>, initial=<no value>, where=<no value>)# Return the maximum along a given axis. Refer to numpy.amax for full documentation. See also · numpy.amax · equivalent function ·
🌐
NumPy
numpy.org › doc › 2.4 › reference › generated › numpy.max.html
numpy.max — NumPy v2.4 Manual
numpy.max(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[source]#
🌐
NumPy
numpy.org › doc › 2.0 › reference › generated › numpy.max.html
numpy.max — NumPy v2.0 Manual
numpy.max(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)[source]#
🌐
EDUCBA
educba.com › home › software development › software development tutorials › numpy tutorial › numpy max
NumPy max | Working of NumPy max with Examples
June 15, 2023 - The max values return are [[76, 89, 76]], the third way where the axis and keepdims parameters are passed as axis=1 and keepdims=False(not keeps the output array dimension same as input dimension array) and the max values return are [89, 55, 76], as we can see in the above output. We hope that this EDUCBA information on “NumPy max” was beneficial to you.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .max()
Python:NumPy | Built-in Functions | .max() | Codecademy
July 2, 2025 - If tuple, finds maximum along multiple axes. out (optional): Alternative output array to store the result. Must have same shape as expected output. keepdims (optional): If True, reduced axes are retained in result as dimensions with size one.
🌐
GitHub
github.com › numpy › numpy › issues › 8710
Add `keepdims` argument to argmin and argmax · Issue #8710 · numpy/numpy
February 27, 2017 - For consistency with min and max, so that the returned object is the same shape.
Author: numpy
Top answer
1 of 2
102

@Ney @hpaulj is correct, you need to experiment, but I suspect you don't realize that summation for some arrays can occur along axes. Observe the following which reading the documentation

>>> a
array([[0, 0, 0],
       [0, 1, 0],
       [0, 2, 0],
       [1, 0, 0],
       [1, 1, 0]])
>>> np.sum(a, keepdims=True)
array([[6]])
>>> np.sum(a, keepdims=False)
6
>>> np.sum(a, axis=1, keepdims=True)
array([[0],
       [1],
       [2],
       [1],
       [2]])
>>> np.sum(a, axis=1, keepdims=False)
array([0, 1, 2, 1, 2])
>>> np.sum(a, axis=0, keepdims=True)
array([[2, 4, 0]])
>>> np.sum(a, axis=0, keepdims=False)
array([2, 4, 0])

You will notice that if you don't specify an axis (1st two examples), the numerical result is the same, but the keepdims = True returned a 2D array with the number 6, whereas, the second incarnation returned a scalar. Similarly, when summing along axis 1 (across rows), a 2D array is returned again when keepdims = True. The last example, along axis 0 (down columns), shows a similar characteristic... dimensions are kept when keepdims = True.
Studying axes and their properties is critical to a full understanding of the power of NumPy when dealing with multidimensional data.

2 of 2
9

An example showing keepdims in action when working with higher dimensional arrays. Let's see how the shape of the array changes as we do different reductions:

import numpy as np
a = np.random.rand(2,3,4)
a.shape
# => (2, 3, 4)
# Note: axis=0 refers to the first dimension of size 2
#       axis=1 refers to the second dimension of size 3
#       axis=2 refers to the third dimension of size 4

a.sum(axis=0).shape
# => (3, 4)
# Simple sum over the first dimension, we "lose" that dimension 
# because we did an aggregation (sum) over it

a.sum(axis=0, keepdims=True).shape
# => (1, 3, 4)
# Same sum over the first dimension, but instead of "loosing" that 
# dimension, it becomes 1.

a.sum(axis=(0,2)).shape
# => (3,)
# Here we "lose" two dimensions

a.sum(axis=(0,2), keepdims=True).shape
# => (1, 3, 1)
# Here the two dimensions become 1 respectively