Euclidean distance of points coordinates in pandas dataframe

前端 未结 2 1414
旧时难觅i
旧时难觅i 2020-12-21 08:47

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

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-21 09:27

    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)
    

提交回复
热议问题