numpy.size#

numpy.size(a,axis=None)[source]#

Return the number of elements along a given axis.

Parameters:
aarray_like

Input data.

axisint, optional

Axis along which the elements are counted. By default, givethe total number of elements.

Returns:
element_countint

Number of elements along the specified axis.

See also

shape

dimensions of array

ndarray.shape

dimensions of array

ndarray.size

number of elements in array

Examples

>>>importnumpyasnp>>>a=np.array([[1,2,3],[4,5,6]])>>>np.size(a)6>>>np.size(a,1)3>>>np.size(a,0)2
On this page