📅  最后修改于: 2022-03-11 14:45:16.189000             🧑  作者: Mango
a = [[1, 2, 3, -1, -2, -3, -4, -1, 1, 2, 1, 2, 3, 2, 5],
[1, 2, 3, -1, -2, -3, -4, -1, 1, 2, 1, 2, 3, 2, 5],
[1, 2, 3, -1, -2, -3, -4, -1, 1, 2, 1, 2, 3, 2, 5]]
b = np.array(a)
def avg(a):
return a[a > 0].mean()
np.apply_along_axis(avg, 1, b)