Can anyone help to explain to me how can I do counting from 2 arrays without any iteration (e.g using numpy)?
Example: I have two numpy arrays, Origin and destiation. Origin and destination can have the same value. Let say I have 6 items in my array
origin = np.array(['LA', 'SF', 'NY', 'NY', 'LA', 'LA'])
dest = np.array(['SF', 'NY', 'NY', 'SF', 'LA', 'LA'])
The first item is from LA-SF, second SF-NY, third NY-NY, and so on.
The result that I want is
array([[1, 0, 1],
[0, 2, 1],
[1, 0, 0]])
where the row refers to origin, first being NY, second being LA, and third being SF, and the column refers to the destination with the same order.
Thank you!