I have a list of points in 3d coordinates system (X, Y, Z). Moreover, each of them have assigned a float value v, so a single point might be described as (x, y, z, v). This list is represented as a numpy array of shape=(N,4). For each 2d position x, y I need to get the maximum value of v. A straightforward but computationally expensive way would be:
for index in range(points.shape[0]):
x = points[index, 0]
y = points[index, 1]
v = points[index, 3]
maxes[x, y] = np.max(maxes[x, y], v)
Is there a more "numpy" approach, which would be able to bring some gain in terms of performance?
np.max(points[:, 3])not sufficient?x, ypair. Basically groupbyx, yand find the max for each group