Answers for "python get average list in 2d array"

0

python get average list in 2d array

import numpy as np
a = [[1,2],[3,4]]
np.mean(a) # (1+2+3+4)/4 = 2.5
np.mean(a, axis=0) # [mean(1,3), mean(2,4)] = [2.0, 3.0]
np.mean(a, axis=1) # [mean(1,2), mean(3,4)] = [1.5, 2.5]
Posted by: Guest on August-30-2021

Python Answers by Framework

Browse Popular Code Answers by Language