For example if i have: a=np.array([[1,1,4,1,4,3,1]]) We can see that we have the number 1 four times, the number 4 twice and 3 only ones. I want to have the following result: array(4,4,2,4,2,1,4) As you can see: each cell is replaced by the count of it's element. How can i do it in the best efficient way? Continue reading...