I have a 2D numpy array as follows:
import numpy as np
a=np.array([[1,2],[1,1], [2,1],[2,2],[3,2],[3,2], [3,1], [4,2],[4,1]])
print(a)
I need to count how many values of 1 or 2 occur in column 2 for each value in column 1. For example when x=3 in column 1, there are two instances of the value 2 and one instance of the value 1 in column 2.
Any direction on how to complete this would be appreciated! I think I could do some sort of for loop with np.unique but I am not sure...