Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to count numpy array elements? [duplicate]

Tags:

python

numpy

I have a numpy Array name odd_num_mul = [ 2 0 0 0 0 12 0 8] I want to count the numbers of elements in this array.For ex - (8 elements in this case). How can I count?

like image 419
Yash Pandey Avatar asked Sep 15 '26 04:09

Yash Pandey


1 Answers

Use arr.size or np.prod(arr.shape)

like image 62
Anurag Reddy Avatar answered Sep 16 '26 19:09

Anurag Reddy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!