I have two numpy arrays, for example:
import numpy as np
a1 = np.linspace(0,2*np.pi,101)
a2 = np.random.choice(a1, 60)
I need to count how many times each value from a1 appears in a2. I can do it with a loop but I was hoping for a better solution.
Solution with a loop:
a3 = np.zeros_like(a1)
for i in range(len(a1)):
a3[i] = np.sum(a2==a1[i])

a1with the count at each index?