I have a 3x3 list and by using numpy - I was able to calculate three numpy array:
mean_1 = np.mean(list, axis=0)
mean_2 = np.mean(list, axis=1)
mean_all = np.mean(list)
Is there a way to create a list out of those numpy arrays?
CodePudding user response:
res = [mean_1, mean_2, mean_all]
CodePudding user response:
Something like this?
import numpy as np
lst = np.array([[1,2,3],[4,5,6],[7,8,9]])
[np.mean(lst, axis=x) for x in [0, 1, None]]
OUTPUT
[array([4., 5., 6.]), array([2., 5., 8.]), 5.0]