I have a numpy ndarray with shape of (30,480,640), the 1th and 2th axis representing locations(latitude and longitute), the 0th axis contains actual data points.I want to us
Explaining @ecatmurs part
u[np.argmax(np.apply_along_axis(np.bincount, axis, indices.reshape(arr.shape),
None, np.max(indices) + 1), axis=axis)]
a little bit more and restructuring it to be more concise when re-reading it (because I used this solution and after a few weeks I was wondering what had happened in this function):
axis = 0
uniques, indices = np.unique(arr, return_inverse=True)
args_for_bincount_fn = None, np.max(indices) + 1
binned_indices = np.apply_along_axis(np.bincount,
last_axis,
indices.reshape(arr.shape),
*args_for_bincount_fn)
most_common = uniques[np.argmax(binned_indices,axis=axis)]