I have a pandas dataframe with six columns, first three columns contain x, y and z reference coordinate, and the next three - coordinates of some
Here's how I do it:
p1 = df[['x1', 'y1', 'z1']] p2 = df[['x2', 'y2', 'z2']] df['dist'] = ((p1 - p2)**2).sum(axis=1) ** 0.5
You might not need any fancy magic here:
df['dist'] = np.sqrt( (df.x1-df.x2)**2 + (df.y1-df.y2)**2 + (df.z1-df.z2)**2)