DEV Community

Jaweher Ben Salah
Jaweher Ben Salah

Posted on

Answer: In numpy.sum() there is parameter called "keepdims". What does it do?

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
…

Top comments (0)