matlab,optimization,vectorization,nested-loops,pdist

You can use efficient euclidean distance calculation as listed in Speed-efficient classification in Matlab for a vectorized solution - %// Setup the input vectors of real and imaginary into Mx2 & Nx2 arrays A = [real(InitialPoints) imag(InitialPoints)]; Bt = [real(newPoints).' ; imag(newPoints).']; %// Calculate squared euclidean distances. This is one...

python,arrays,matrix,distance,pdist

This seems to work: for i in range(S.shape[0]): M = np.matrix( [S['x'][i], S['center'][i]] ) print pdist(M, 'euclidean') or with iterrows(): for row in S.iterrows(): M = np.matrix( [row[1]['x'], row[1]['center']] ) print pdist(M, 'euclidean') Note that the creation of a matrix isn't necessary, pdist will handle a python list of lists...

python,numpy,scipy,lambda,pdist

If you really must use pdist, you first need to convert your strings to numeric format. If you know that all strings will be the same length, you can do this rather easily: numeric_d = d.view(np.uint8).reshape((len(d),-1)) This simply views your array of strings as a long array of uint8 bytes,...