I am working on Manhattan distance. It works well with the simple for loop. But I am trying to avoid this for loop.
import numpy as np
import random
A = np.random.randint(5, size=(10, 5))
B = [1, 3, 5, 2, 4]
for i in range(10):
dist = sum(abs(A[i]-B))
print("Distances: ", dist)
Is there any optimal way than this? such as using advanced indexing.. Thank you for the guidance.