9951 explained code solutions for 126 technologies


python-numpyGet array average


import numpy as np
arr = np.array([[1, 2], [3, 4]])
average = np.average(arr)ctrl + c
import numpy as np

load Numpy module for Python

np.array

declare Numpy array

[[1, 2], [3, 4]]

sample matrix data

np.average

returns given array average