I am calculating Euclidean distances in python. I want to learn how to calculate it without using a for loop. Here is my code,
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 = np.linalg.norm(A[i]-B)
print("Distances: ", dist)
Is there anyway in which I can use advanced indexing or any other techniques to calculate the distances without using a for loop? thanks.