How to find the average in NumPy

You can find the average in the NumPy with the following code. If you want to learn Python, I highly recommend reading This Book.

How to average in NumPy
How to find the average in NumPy

Example 1

import numpy as np

a = np.array([1, 2, 3, 4, 5])
average = np.average(a)

print(average)

Output

3.0

Example 2

import numpy as np

a = np.array([[1, 2, 3, 4, 5],[5, 10, 15, 20, 25]])
average = np.average(a)

print(average)
9.0

People are also reading:

Best Python Books

What is Computer Vision? Examples, Applications, Techniques

Books for Machine Learning (ML)

Free Learning Resources

Leave a Comment

Your email address will not be published.