Given array a
, count occurrences and stack.
e.g. a = np.array([0, 0, 1, 1, 2, 1, 0, 2, 3, 0, 1])
then counts = np.dstack(np.unique(a, return_counts=True))
gives
array([[[0, 4],
[1, 4],
[2, 2],
[3, 1]]])
Given array a
, count occurrences and stack.
e.g. a = np.array([0, 0, 1, 1, 2, 1, 0, 2, 3, 0, 1])
then counts = np.dstack(np.unique(a, return_counts=True))
gives
array([[[0, 4],
[1, 4],
[2, 2],
[3, 1]]])