1a = [[1, 2, 3, -1, -2, -3, -4, -1, 1, 2, 1, 2, 3, 2, 5],
2 [1, 2, 3, -1, -2, -3, -4, -1, 1, 2, 1, 2, 3, 2, 5],
3 [1, 2, 3, -1, -2, -3, -4, -1, 1, 2, 1, 2, 3, 2, 5]]
4
5b = np.array(a)
6
7def avg(a):
8 return a[a > 0].mean()
9
10np.apply_along_axis(avg, 1, b)