# Numpy size() function | Python

In Python, `numpy.size()` function count the number of elements along a given axis.

Synatx: numpy.size(arr, axis=None)

Parameters:
arr: [array_like] Input data.
axis: [int, optional] Axis along which the elements are counted. By default, give the total number of elements.

Returns: [int] Return the number of elements along a given axis.

Code #1 :

 `# Python program explaining ` `# numpy.size() method  ` ` `  `# importing numpy  ` `import` `numpy as np ` ` `  `# Making a random array  ` `arr ``=` `np.array([[``1``, ``2``, ``3``, ``4``], [``5``, ``6``, ``7``, ``8``]]) ` ` `  `# By default, give the total number of elements. ` `print``(np.size(arr)) `

Output:

```8
```

Code #2 :

 `# Python program explaining ` `# numpy.size() method  ` ` `  `# importing numpy  ` `import` `numpy as np ` ` `  `# Making a random array  ` `arr ``=` `np.array([[``1``, ``2``, ``3``, ``4``], [``5``, ``6``, ``7``, ``8``]]) ` ` `  `# count the number of elements along the axis. ` `print``(np.size(arr, ``0``)) ` `print``(np.size(arr, ``1``)) `

Output:

```2
4
```
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Improved By : VarunPandey

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.