Calculating mean values along masking numpy array

Viewed 11

I have a 2d NumPy array:

# x, y, z, mask_id
data = np.array([[ 3.28246069,  3.63800144, -1.66515279,  0],
                 [ 3.28246069,  3.63800144, -1.66515279,  0],
                 [ 0.,  0., 0.,  1]])

This is the result what I expect:

# mean value of each mask id
array([[3.28246069,  3.63800144, -1.66515279], [0, 0, 0]])

I want to calculate mean value from same mask id. Is there any fast method?

0 Answers
Related