Return the number of elements along a given axis.
Input data.
Axis or axes along which the elements are counted. By default, give the total number of elements.
Changed in version 2.4: Extended to accept multiple axes.
Number of elements along the specified axis.
See also
shapedimensions of array
ndarray.shapedimensions of array
ndarray.sizenumber of elements in array
>>> import numpy as np >>> a = np.array([[1,2,3],[4,5,6]]) >>> np.size(a) 6 >>> np.size(a,axis=1) 3 >>> np.size(a,axis=0) 2 >>> np.size(a,axis=(0,1)) 6
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/generated/numpy.size.html